Skip to content
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

planning towards supporting fully mixed sync/async hook calling #378

Open
RonnyPfannschmidt opened this issue Mar 23, 2023 · 4 comments
Open

Comments

@RonnyPfannschmidt
Copy link
Member

cc @simonw

this is a rough outline of supporting async hook calls and awaitable results in

the starting point will be a async hook caller that will call sync and async hook, deferring all awaitables to the event loop

nesting like async->sync->async will trigger failures when awaitables are encountered in the inner loop

the next level will be deferring all sync calls to a thread executor
any sync call that triggers a awaitable, will steal one thread of that pool , this is considered acceptable as execution is typically expected to be fairly non-concurrent (based on pytest)

a own threadpool with a maxium size of 10 ? shal be used (this accounts for the expectation that hooks run in order and should not nest to arbitrary levels)

nonblocking sync hooks may be marked as nonblocking
in which case they may run in the mainloop, as before nesting async into sync will trigger errros

the primary use case for nonblocking sync hooks is to support being nested into other legacy hooks without causing issues but transparently working with modern hook calls

@bluetech
Copy link
Member

Why is mixing sync and async hooks needed?

@RonnyPfannschmidt
Copy link
Member Author

To migrate ecosystems

@nicoddemus
Copy link
Member

Is this intended to support only asyncio, or open to other async libraries?

@RonnyPfannschmidt
Copy link
Member Author

Any async, end goal here is to prepare the possible recoloring of the pytest internals

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

No branches or pull requests

3 participants