Skip to content

Conversation

@slafs
Copy link
Contributor

@slafs slafs commented Jul 9, 2025

Fixes #482

Run sync tasks within copied context.

This is heavily inspired by starlette's run_in_threadpool function
introduced in Kludex/starlette#192.

Nowadays, starlette is just using anyio.to_thread.run_sync, which does a bunch of extra stuff too,
but from my (limited) understanding,
introducing that would require some changes to the architecture of the project itself 🤔. IDK.

slafs added 2 commits July 9, 2025 17:34
The one for sync fails ATM.
For async is OK.
Run sync tasks within copied context.

This is heavily inspired by starlette's `run_in_threadpool` function
introduced in Kludex/starlette#192.
@s3rius
Copy link
Member

s3rius commented Oct 23, 2025

Thanks for your contribution.

@s3rius s3rius merged commit 4765e3e into taskiq-python:master Oct 23, 2025
@slafs slafs deleted the preserve-ctx-for-sync-tasks branch October 23, 2025 11:32
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.

Sync tasks loose contextvars

2 participants