Open teocns opened 2 weeks ago
I think I would agree with the comment by tiangolo https://github.com/fastapi/fastapi/discussions/6395#discussioncomment-5129869. If gevent
is doing some monkey patching of Python internals then we can't guarantee that it will work. It sounds like nobody should be using gevent
😅.
That being said I'd be interested to understand more about what is going wrong. If you can share some small examples of how to reproduce the issues you are seeing I can dig in and see if there are any small things we can change to get things to play nicely.
Out of interest if creating a sync-native fork is your current workaround why not use a sync-native library like kubernetes
or pykube-ng
? I'm mainly asking because I'm excited that you seem to like kr8s enough to perservere here.
I'm mainly asking because I'm excited that you seem to like kr8s enough to perservere here.
That answers it partially 💯 on the other hand my backend's implementation is already founded around kr8s' APIObject
, serialization and lookup features - would've taken me longer to adopt a different API than quickly refactoring async-to-sync.
If you can share some small examples of how to reproduce the issues you are seeing I can dig in and see if there are any small things we can change to get things to play nicely.
I think this is easy to reproduce: setup flask w/ gevent, and the issue happens exactly when invoking asgiref.async_to_sync
, which flask[async]
uses in current_app.ensure_sync
. You will see a bunch of nasty runtime errors coming out of the threading
module...
It sounds like nobody should be using gevent 😅.
I'm in grief
Could you share a step by step that I can copy and paste, I'm not familiar with gevent
and flask[async]
.
I'll be happy to, give me a few days and I'll setup a branch for us 👍
Which project are you reporting a bug for?
kr8s
What happened?
When I was just about to celebrate testing a flask app in production.... kr8s took it away from me 🤣
So it turns out it doesn't play well with wsgi. From my analysis it's merely due to the
async
keyword-statements whichgevent
hallucinates on top of, as it runs its own internal monkey patching on python'sthreading
system libraryAs a temporary fix, I'm now running a sync-native fork.
Looking for ideas and brainstorming onto ways we can merge this, if it's the case
Anything else?
https://github.com/fastapi/fastapi/discussions/6395