-
-
Notifications
You must be signed in to change notification settings - Fork 753
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
Support custom IOLOOPs #2435
base: master
Are you sure you want to change the base?
Support custom IOLOOPs #2435
Conversation
7706714
to
03ec1b0
Compare
32e28d0
to
46078a9
Compare
38ee9b2
to
6c5b1a1
Compare
@@ -70,10 +71,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: | |||
|
|||
self.config = Config(**config_kwargs) | |||
|
|||
def init_process(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why @graingert removed this from here, please make sure its ok :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the setup_event_loop method is removed, so we don't need to call it in init_process. We also don't need to have a method just to call super - that's the default
6c5b1a1
to
fcb1cbe
Compare
Any updates regarding this? @Kludex |
Hey guys, Thanks :) |
@Kludex Are you a maintainer? |
if sys.platform == "win32" and not use_subprocess: | ||
return asyncio.ProactorEventLoop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reference for me later: python/cpython#122240
this is a bit more important to get done as 3.14 deprecated the policy system, and we need a way to enable eager tasks |
Question to my future self, or others: Just to confirm, this is not a breaking change, given that |
it should be not a breaking change.... mostly there's some differences - we're not using the broken and deprecated policy system anymore so that means anyone using asyncio on windows from a thread will get the default asyncio.EventLoop in their asyncio.run calls, rather than the SelectorEventLoop. There's another change in that setting the event loop factory to "not None" results in asyncio.set_event_loop() not being called, but this is a no-op on windows anyway. (We do still call set_event_loop on posix, where on old python versions on linux this has observable differences with how child watchers work) |
@Kludex ok I've stopped fiddling with this PR now - it's good to be reviewed |
Summary
This is merge of two PR's
Allow passing a custom loop setup function instead of None #2391
Support passing a custom IOLoop setup function in order to support running
uvicorn
in custom ioloop implementation other that the default anduvloop
.For example this feature will allow using this monitored IOLoop inside
uvicorn
applications :)Link to discussions thread - Add support for custom ioloop implementations #2256
use asyncio.run(..., loop_factory) to avoid asyncio.set_event_loop_policy #2130
set_event_loop_policy
will be deprecated in python 3.13 anduvloop.EventLoopPolicy
is deprecated already, this backports and uses the preferredloop_factory
keyword to configureasyncio.run
Checklist