-
Notifications
You must be signed in to change notification settings - Fork 887
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
Pyramid 2.0 asyncio support #3391
Comments
This issue is a duplicate of #2603 and I don't want to have two issues on async support open right now. I'm going to close at least one of them. I don't think pyramid 2.0 is relevant here until someone demonstrates a working reference implementation / pull request and we can see what backward incompatible changes would be made to pyramid to support any asyncio features. I strongly disagree with the idea that pyramid would work in some sort of "dual" mode and care at all about any thread pools, etc. This stuff is entirely up to the runtime itself that is invoking pyramid's router and the question is how much of pyramid's pipeline needs to be tweaked to support an async call stack. WSGI itself does not support async code, and that is the only entry point into pyramid's router right now. This will need to change. There are basically two options:
The first option (async-in-sync) is doable right now because you can just start an event loop in your view and add async work to it. Alternatively you can define a shared event loop running in another thread. No one is really interested in these options. The second option is that pyramid adopts an ASGI protocol (see the The question is basically, how do we go about modifying pyramid internals to handle an ASGI call stack all the way down to a view callable. This basically means that pyramid needs to expect a lot of hooks to return futures and it needs to be able to deal with them. |
I should also point out that pyramid has no chance of modifying its router to support an ASGI call stack until webob itself supports async IO. This means that anywhere that webob touches IO (primarily the |
I think I used some confusing terminology here, ASGI like approach is what I meant when I mentioned separate parts of application:
I'm not sure why the Also as for webob support, |
It's not interesting because it can already be done, easily, with no changes to Pyramid, right now using a wsgi container in any asyncio http server and using
|
After discussion on IRC and some clarifications seems that example here https://docs.pylonsproject.org/projects/pyramid-cookbook/en/latest/deployment/asgi.html seems to be the best route to go. |
Thanks @ergo! This discussion helped me think a bit further about what Pyramid would need to do in order to support a fully async call stack and it seems pretty daunting, requiring at least changes to webob and the z.i component registry (for async events) before we can think about changing Pyramid itself. |
It would be great to implement easy asyncio support for pyramid 2.0.
This issue should serve as a plan to implement that.
I would suggest we use python 3.6/3.7 as a base requirement for the module.
By default pyramid should work in a standard "sync" mode same as django or flask and provide decorators/factories for optional asynchronous views and machinery.
Pyramid would "reserve" a single thread for asyncio execution and all async parts of application code would be marked accordingly by async/await or decorator.
Links for inspiration:
https://github.com/housleyjk/aiopyramid/tree/master/aiopyramid
https://github.com/mardiros/pyramid_asyncio
https://aiohttp-wsgi.readthedocs.io/en/stable/installation.html
The text was updated successfully, but these errors were encountered: