-
Notifications
You must be signed in to change notification settings - Fork 2
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
Isolated usage of greenlets #22
Comments
Are you able to give a reproducer of the conflict that doesn't have dependencies outside of greenback, sqlalchemy, and some async library? I'm not familiar with Prefect at all, and only a little bit familiar with sqlalchemy's use of greenlets. |
Hey @oremanj — I don't work at Prefect anymore but I was the one looking into this originally and am quite curious if there's a solution. I'll see if I can find or create an example. It's possible @jakekaplan could provide one as well. |
Okay it's kind of late and I don't remember all the details so forgive me if these are not correct, but I can create a few symptoms as follows: import greenback
import sqlalchemy
import asyncio
def fails():
greenback.await_(asyncio.sleep(0)) # ERROR
# TypeError: object NoneType can't be used in 'await' expression
async def main():
await greenback.ensure_portal()
greenback.await_(asyncio.sleep(0)) # OK
await sqlalchemy._util.concurrency.greenlet_spawn(fails)
if __name__ == "__main__":
asyncio.run(main()) import greenback
import sqlalchemy
import asyncio
def fails():
sqlalchemy._util.concurrency.await_only(asyncio.sleep(0)) # OK
greenback.await_(asyncio.sleep(0)) # ERROR
# TypeError: object Value can't be used in 'await' expression
async def main():
await greenback.ensure_portal()
greenback.await_(asyncio.sleep(0)) # OK
await sqlalchemy._util.concurrency.greenlet_spawn(fails)
if __name__ == "__main__":
asyncio.run(main()) with
|
@oremanj just wondering if you had a chance to look into this and if I can do anything else to help. Thanks! |
Hi, sorry for the delay here. It looks like sqlalchemy stores a link to the parent/driver greenlet explicitly in its child greenlet, instead of using |
Thanks for looking into it. I tried to make some changes in that vein and must admit I'm still a bit confused. If you can provide more guidance I'm happy to play with it some more. Otherwise, I understand that you're busy. |
Thanks for the library!
Prefect has been doing some experimenting with greenback here and ran into this limitation because SQLAlchemy is also used:
The workarounds for this such as running in a separate thread have their own drawbacks
Is this kind of isolation something that could be handled at the
greenback
level? Or is this more of a limitation of the way greenlets and/or SQLAlchemy works?The text was updated successfully, but these errors were encountered: