Skip to content

sync primitives#5848

Merged
willmcgugan merged 2 commits into
mainfrom
thread-init
Jun 8, 2025
Merged

sync primitives#5848
willmcgugan merged 2 commits into
mainfrom
thread-init

Conversation

@willmcgugan

Copy link
Copy Markdown
Member

Fixes #5845

A recent update made the threading objects instantiate lazily, with cached_property. This was done because in Python3.8 objects like Event are bound to the thread where they are instantiated, and would break if you tried to use them in another thread with a different async loop.

Unfortunately that fix broke the thread safety of post_message. This update forces the async primitives to instantiate in the async task where they are used.

This is a bit of a patch until we drop 3.8 (soon).

@willmcgugan willmcgugan merged commit 11266cb into main Jun 8, 2025
23 checks passed
@willmcgugan willmcgugan deleted the thread-init branch June 8, 2025 14:38
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.

post_message is thread-unsafe now that _message_queue is a cached_property

1 participant