You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/develop/python/core-application.mdx
+18-4Lines changed: 18 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,8 @@ To return a value of the Workflow, use `return` to return an object.
119
119
120
120
To return the results of a Workflow Execution, use either `start_workflow()` or `execute_workflow()` asynchronous methods.
121
121
122
+
For performance and behavior reasons, users should pass through all modules, including Activities, Nexus services, and third-party plugins, whose calls will be deterministic using [`imports_passed_through`](https://python.temporal.io/temporalio.workflow.unsafe.html#imports_passed_through) or at Worker creation time by customizing the runner's restrictions with [`with_passthrough_modules`](https://python.temporal.io/temporalio.worker.workflow_sandbox.SandboxRestrictions.html#with_passthrough_modules).
Copy file name to clipboardExpand all lines: docs/develop/python/python-sdk-sandbox.mdx
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Temporal's Python SDK uses a sandbox environment for Workflow runs to make devel
36
36
If a Workflow Execution performs a non-deterministic event, an exception is thrown, which results in failing the Task Worker.
37
37
The Workflow will not progress until the code is fixed.
38
38
39
-
The Temporal Python sandbox offers a mechanism to _pass through modules_ from outside the sandbox. By default, this includes all standard library modules and Temporal modules. For performance and behavior reasons, users are encouraged to pass through all third-party modules whose calls will be deterministic. For more information, see [Passthrough modules](#passthrough-modules).
39
+
The Temporal Python sandbox offers a mechanism to _pass through modules_ from outside the sandbox. By default, this includes all standard library modules and Temporal modules. For performance and behavior reasons, users should pass through all models, Activities, Nexus services, or other modules that are in separate files whose calls will be deterministic. For more information, see [Passthrough modules](#passthrough-modules).
40
40
41
41
## How it works
42
42
@@ -108,14 +108,13 @@ The [`SandboxRestrictions`](https://python.temporal.io/temporalio.worker.workflo
108
108
109
109
### Passthrough modules
110
110
111
-
By default, the sandbox completely reloads non-standard-library and non-Temporal modules for every workflow run. Passing through a module means that the module will not be reloaded every time the Workflow runs. Instead, the module will be imported from outside the sandbox and used directly in the Workflow. This can improve performance because importing a module can be a time-consuming process, and passing through a module can avoid this overhead.
112
-
:::note
111
+
By default, the sandbox completely reloads non-standard-library and non-Temporal modules for every Workflow run. Passing through a module means that the module will not be reloaded every time the Workflow runs. Instead, the module will be imported from outside the sandbox and used directly in the Workflow. This can improve performance because importing a module can be a time-consuming process, and passing through a module can avoid this overhead.
113
112
113
+
:::note
114
114
It is important to note that you should only import _known-side-effect-free_ third-party modules: meaning they don't have any unintended consequences when imported and used multiple times. This is because passing through a module means that it will be used multiple times in a workflow without being reloaded, so any side effects it has will be repeated. For this reason, it's recommended to only pass through modules that are known to be deterministic, meaning they will always produce the same output given the same input.
115
-
116
115
:::
117
116
118
-
One way to pass through a module is at import time in the workflow file using the [`imports_passed_through`](https://python.temporal.io/temporalio.workflow.unsafe.html#imports_passed_through) context manager.
117
+
One way to pass through a module is at import time in the Workflow file using the [`imports_passed_through`](https://python.temporal.io/temporalio.workflow.unsafe.html#imports_passed_through) context manager.
119
118
120
119
```python
121
120
# my_workflow_file.py
@@ -130,7 +129,7 @@ class MyWorkflow:
130
129
# ...
131
130
```
132
131
133
-
Alternatively, this can be done at worker creation time by customizing the runner's restrictions.
132
+
Alternatively, this can be done at Worker creation time by customizing the runner's restrictions.
0 commit comments