Skip to content

Don't use threadsafe variant in signal_event#770

Merged
frenck merged 1 commit intomainfrom
drop-threadsafe-variant-in-singal-event
Jun 24, 2024
Merged

Don't use threadsafe variant in signal_event#770
frenck merged 1 commit intomainfrom
drop-threadsafe-variant-in-singal-event

Conversation

@agners
Copy link
Copy Markdown
Collaborator

@agners agners commented Jun 24, 2024

All calls to signal_event are made in the asyncio event loop thread. Therefore, we don't need to use the threadsafe variant of call_soon() anymore.

This was anyways a bit brittle as asyncio.create_task() is not threadsafe, so calling signal_event from a different thread was not really safe.

All calls to signal_event are made in the asyncio event loop thread.
Therefore, we don't need to use the threadsafe variant of call_soon()
anymore.

This was anyways a bit brittle as asyncio.create_task() is not
threadsafe, so calling signal_event from a different thread was not
really safe.
@agners agners added the maintenance Code (quality) improvement or small enhancement which not a new feature label Jun 24, 2024
@agners
Copy link
Copy Markdown
Collaborator Author

agners commented Jun 24, 2024

Afaik, in practice this won't really make a difference as it is ok to call call_soon_threadsafe() from the event loop thread. But we'll get a runtime exception in the future in case we (accidentially) call signal_event() from another thread again.

@frenck frenck merged commit b21a6dd into main Jun 24, 2024
@frenck frenck deleted the drop-threadsafe-variant-in-singal-event branch June 24, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Code (quality) improvement or small enhancement which not a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants