"RestrictedWorkflowAccessError: Cannot access os.stat.__call__", but I never call os.stat

I’m working with the python-sdk on MacOS.

Developing a workflow involving psycopg2. Nowhere in my workflow do I import os, but I am frequently running into issues where my worker throws exceptions like

  File "/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/linecache.py", line 72, in checkcache
    stat = os.stat(fullname)
  File "/Users/seanbloomfield/.virtualenvs/migrate/lib/python3.13/site-packages/temporalio/worker/workflow_sandbox/_restrictions.py", line 964, in __call__
    state.assert_child_not_restricted("__call__")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/seanbloomfield/.virtualenvs/migrate/lib/python3.13/site-packages/temporalio/worker/workflow_sandbox/_restrictions.py", line 792, in assert_child_not_restricted
    raise RestrictedWorkflowAccessError(
        f"{self.name}.{name}", override_message=matcher.leaf_message
    )
temporalio.worker.workflow_sandbox._restrictions.RestrictedWorkflowAccessError: Cannot access os.stat.__call__ 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.

I only have a loose understanding the temporal’s determinism requirements, but this traceback never points me to the line of code I wrote that violates determinism. Is there a way to figure out what line of code that I own is leading to the violation?

revert back to using python 3.12, shouldnt be getting this then, also see issue here

1 Like