[Bug] Gunicorn/Flask server hanging when exception raised in pl.process.*
#108
Labels
bug
Something isn't working
pl.process.*
#108
Describe the bug
I have a Flask server that uses Gunicorn as a WSGI server. It does some HTTP request gateway routing using the
multiprocessing
library under the hood. Inside one of the HTTP request handler, I call Pypeln for some multiprocessing workload.Things are fine if Pypeln finishes successfully. However, if the pypeln function raises an exception, the exception would be raised by the
main_queue
, but hang and never get past thepl.process.run
call.Note: it's the combination of
gunicorn
andpypeln
that's causing this bug. When I swapped out Gunicorn with another WSGI server Waitress, Pypeln returns the error just fine. Moreover, when I remove the WSGI server altogether and simple use vanilla Flask, there was also no issue.Minimal code to reproduce
Pypeln code:
For Flask/Gunicorn setup:
Actual behavior
The above code would hang at
pl.process.run(stage)
, and I will see the following in stdout:At this point, the Flask server is hanging, and I'll need to SIGINT to recover. Setting
timeout
in themap
function also does not help. Seems like the Pypeln process is probably completely killed by Gunicorn.Expected behavior
If I don't run this script with Gunicorn, the exception is successfully caught and returned.
Library Info
Please provide os info and elegy version.
The text was updated successfully, but these errors were encountered: