Skip to content

Commit 5f2a4e1

Browse files
committed
EDU-4430 cleaned explanation
1 parent 987ad6c commit 5f2a4e1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

docs/develop/python/python-sdk-sync-vs-async.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,37 +71,38 @@ such as `aiohttp` or `httpx`. Otherwise, use a synchronous Activity.
7171

7272
Python workers have following components for executing code:
7373

74-
- Your event loop, which runs tasks from async activities **plus the rest of Temporal, such as communicating with the server**.
74+
- Your event loop, which runs tasks from async activities **plus the rest of the Temporal Worker, such as communicating with the server**.
7575
- An executor for executing activity tasks from synchronous activities. A thread pool executor is recommended.
76-
- A thread pool executor for executing workflow tasks (see forum post [here](https://community.temporal.io/t/whats-the-workflow-task-executor-in-the-python-worker-configuration/16965)).
76+
- A thread pool executor for executing workflow tasks.
7777

7878
> See Also: [docs for](https://python.temporal.io/temporalio.worker.Worker.html#__init__) `worker.__init__()`
7979
8080
### Activities
8181

82-
- The activities and the temporal worker SDK code both run in whatever event loop the user gives the worker (which is often the default asyncio event loop).
82+
- The activities and the temporal worker SDK code both run the default asyncio event loop or whatever event loop you give the Worker.
8383
- Synchronous Activities run in the `activity_executor`.
8484

8585
### Workflows
8686

8787
Since workflow tasks (1) are CPU bound, (2) need to be timed out for deadlock detection, and (3) need to not block other workflow tasks, they are run in threads. The `workflow_task_executor` is the thread pool these tasks are run on.
8888

89-
This can be confusing at first because Workflow Definitions are `async`, but this `async` is not referring to the standard event loop -- it is referring to the workflow's own SDK event loop.
89+
The fact that Workflow Tasks run in a thread pool can be confusing at first because Workflow Definitions are `async`.
90+
The key differentiator is that the `async` in Workflow Definitions is not referring to the standard event loop -- it is referring to the workflow's own event loop.
9091
Each workflow gets its own “workflow event loop”, which is deterministic, and described in [the Python SDK blog](https://temporal.io/blog/durable-distributed-asyncio-event-loop#temporal-workflows-are-asyncio-event-loops).
91-
The workflow event loop doesn't constantly loop it just gets cycled through during a workflow task to make as much progress as possible on any all of its futures.
92+
The workflow event loop doesn't constantly loop -- it just gets cycled through during a workflow task to make as much progress as possible on all of its futures.
9293
When it can no longer make progress on any of its futures, then the Workflow Task is complete.
9394

94-
### Number of cores
95+
### Number of CPU cores
9596

96-
The only ways to use more than one CPU core in a python worker (considering the GIL) are:
97+
The only ways to use more than one core in a python worker (considering Python's GIL) are:
9798

98-
- Run the sync activities in a process pool executor, but a thread pool executor is recommended.
9999
- Run more than one worker process.
100+
- Run the sync activities in a process pool executor, but a thread pool executor is recommended.
100101

101102
### Separating Activity and Workflow Workers
102103

103104
To reduce the risk of event loops or executors getting blocked,
104-
some users choose to deploy separate workers for workflow tasks and activity tasks.
105+
some users choose to deploy separate Workers for Workflow Tasks and Activity Tasks.
105106

106107
## Activity Definition
107108

0 commit comments

Comments
 (0)