-
-
Notifications
You must be signed in to change notification settings - Fork 499
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 trio for structured async concurrency #1057
Comments
I have separated the non-blocking part of the communication from the waiting. Using two different waiting function it is already possible to have a sync progress and an asyncio-based progress. There are some details at https://www.varrazzo.com/blog/2020/03/26/psycopg3-first-report/ Do you think trio could use the same code, only replacing the wait function? |
@dvarrazzo Really cool to see the beginning of psycopg3, it's long awaited. |
@yogevyuval It's up to them to work asynchronously, we can only collaborate by not blocking. They have to call us asynchronously, being async is a different interface, as explained in the previous article. |
@dvarrazzo - unfortunately I'm just a I don't want @njsmith or @agronholm to feel pressured to weigh in, especially with everything going on in the world, but I think my ping in gitter likely got lost in the noise - it's not a particularly good medium for keeping track of or searching for past issues. |
@dhirschfeld I don't think a chat is a good medium to remember things, no. You can totally open a bug report to tell them of the library: If they are interested they can look into it further, otherwise they can dismiss it. I don't think that's putting them under undue pressure. |
I'm the author of AnyIO. I just had a cursory read of the blog post and would like to point out that |
Hi @agronholm, the way I've designed the thing, the main loops interacting with the database (connection and querying) are independent from how you wait. I've done a few tests and it seems easy to create a wait function using I have a couple of observations:
So I guess with a bit of work things can work. |
The problem with this is that IOCP on Windows does not support waiting for readability or writability. Instead it lets you wait for the completion of a read or write operation. For this reason, AnyIO 2.0 will not have the functionality for waiting for readability or writability. |
AnyIO 1.x does not work with ProactorEventLoop which is the default on Python 3.8 on Windows. AnyIO 2 does, but the cost was letting the aforementioned functions go. |
I'm pretty sure the need for readability/writability checking is baked into libpq, so it's not something psycopg3 can change. Trio and uvloop do support waiting for readability/writability on Windows (via IOCP), so I guess anyio 2 could support that on most platforms (trio everywhere, asyncio on unix, asyncio on Windows with non-default event loops like |
I reluctantly agree. |
Hello Trio people, psycopg is due to release in a few days now. Would you like to check if it is compatible with trio, or if it can be made easily so (take a look at how I am closing this ticket because it's no more psycopg2 matter. Please use psycopg/psycopg#29 or open new tickets in the psycopg 3 repos if needed Cheers! |
trio
is a Python library for structured async concurrency. As atrio
user it would be great if asyncpsycopg3
could supporttrio
as well asasyncio
.The easiest way to support both async frameworks would be to use the
anyio
library.The text was updated successfully, but these errors were encountered: