Skip to content

EDU-4430 python sync vs async #3578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 9, 2025
Merged

EDU-4430 python sync vs async #3578

merged 13 commits into from
Jun 9, 2025

Conversation

GSmithApps
Copy link
Contributor

@GSmithApps GSmithApps commented May 13, 2025

What does this PR do?

Merges this doc into this docs page

Note

When we merge this, we should also merge this.

from temporalio import activity
- Your event loop, which runs tasks from async activities **plus the rest of Temporal, such as communicating with the server**.
- An executor for executing activity tasks from synchronous activities. A thread pool executor is recommended.
- 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)).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just port this content into the docs directly? It's best to avoid external links when able, and this content seems relevant to this page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it. Done 👍

return translation
```

### Running synchronous code from an asynchronous function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this entire section, according to the Python SDK readme, both of those options (run_in_executor and to_thread) are disabled in our event loop. https://github.com/temporalio/sdk-python?tab=readme-ov-file#asyncio-and-determinism

Copy link
Contributor Author

@GSmithApps GSmithApps May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment! Our event loop and that section of the readme apply to the custom event loop in workflows, not activities, so IIUC the custom event loop doesn’t apply here 👍

I see that the section heading could be confusing though so I changed it from “Running synchronous code from an asynchronous function” to “Running synchronous code from an asynchronous activity

@MasonEgger MasonEgger merged commit 230c6e6 into main Jun 9, 2025
6 checks passed
@MasonEgger MasonEgger deleted the EDU-4430 branch June 9, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants