gevent cooperative multitasking appears to break Connexion v3 FlaskApp? #1998
Replies: 2 comments
-
I hope someone will comment on the breakage. Maybe the connexion migration guide should mention this? I expect I'm not the only person trying to migrate a Connexion v2 app who chose to use I tried using |
Beta Was this translation helpful? Give feedback.
-
From my (very limited) experience, a lot of flask-centric implementations need a big overhaul when switching to Connexion 3. That being said: Are you sure you really need gevent? (also with Connexion 2.x) However if you just want to process a few requests in parallel and you don't need all requests in the same process, there is the traditional approach of using gunicorn + multiple workers which is way less complex than using gevent. My gut feeling is that instead of gevent, you could use a full async app with Connexion 3. |
Beta Was this translation helpful? Give feedback.
-
I am trying to upgrade an app from Connexion v2 to v3. The old app uses the FlaskApp and gevent-provided cooperative multi-tasking so the server can process multiple requests in parallel. The old approach of calling the
gevent.patch_all()
function at start seems to break connexion. From what I can see, requests to the Connexion server don't finish, they just hang.To reproduce the behavior, find the Connexion
helloworld
example and add the following as the first line inhello.py
:Install the prereqs and starting the server:
The startup takes a second longer than before, but no complaints appear. Then try to load the Swagger UI at http://127.0.0.1:8080/openapi/ui/
In my experience this /never finishes/ it just loads forever. Then hit Ctrl-C to interrupt the server. It responds
Shutting down
but hangs again, a second Ctrl-C is required to make it stop.Versions: Python 3.12, connexion 3.1.0, flask 3.1.0 , gevent 24.11.1.
Is this enough information? Please advise, thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions