A spot where I slipped up in trying to adopt Temporal in an existing Python project and then again in starting a new Python project was in defining a Workflow that invokes an Activity that calls a third party library. Temporal outputs an error message with a long stacktrace that I vaguely understood but didn’t immediately know the solution to

raise RestrictedWorkflowAccessError(f"{self.name}.{name}")
temporalio.worker.workflow_sandbox._restrictions.RestrictedWorkflowAccessError: Cannot access http.server.BaseHTTPRequestHandler.responses from inside a workflow. If this is code from a module not used in a workflow or known to only be used deterministically from a workflow, mark the import as pass through.

The message itself is very informative “mark the import as pass through”, but requires a follow up search to find the right snippet to get right. I also overlooked the note about importing Activities in Python, mentioned in the Getting Started Guide.

# Import activity, passing it through the sandbox without reloading the module
with workflow.unsafe.imports_passed_through():
    from activities import say_hello