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

Add support for synchronous event loops #14

Open
tzickel opened this issue May 24, 2020 · 4 comments
Open

Add support for synchronous event loops #14

tzickel opened this issue May 24, 2020 · 4 comments

Comments

@tzickel
Copy link

tzickel commented May 24, 2020

The same principle that exists in the asynchronous world, exists in the synchronous world as well.

I've been bitten enough by gevent's monkey patching, that I think that if library writers had an option to detect a code is running via a greenlet or normal (threaded?), it could create code that automatically knows which primitives to use.

@jamadden This could make libraries like this (which is the basis of httpx) auto detect and use gevent as well (without monkey patching) ?
https://github.com/encode/httpcore/tree/master/httpcore/_backends

@agronholm
Copy link
Contributor

I just don't understand how this would make the code manifest the necessary await etc. statements. Enlighten us please?

@graingert
Copy link
Member

graingert commented Mar 10, 2021

there's also the case for twisted in greenlet or asyncio in greenlet (and them both), eg running async sqlalchemy on pytest-twisted

@tzickel
Copy link
Author

tzickel commented Mar 11, 2021

I do not understand how gevent is related to async/await. As said in the OP, I would like the option for sniffio to be able to report synchronous event loops such as running inside a greenlet. Then when writing for example a sync library like redis-py it could query if it's running under a greenlet and do different code instead of using regular I/O (thus not requiring monkey patching).

@agronholm
Copy link
Contributor

Ah, I got confused. Nevermind!

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