Closed daltonmatos closed 7 years ago
I am stumbling upon this issue with gunicorn==18.0
. In the gunicorn_conf.py I have worker_class = 'gevent'
, preload_app = True
and custom pre_fork
, on_starting
and on_reload
functions.
Putting these lines on top of the gunicorn_conf.py file seems to solve the issue for me:
import gevent.monkey
gevent.monkey.patch_thread()
Update: I've had these lines in my gunicorn.conf. Getting rid of them solved the issue without monkey-patching.
import django
django.setup()
Because of them django initiated the connection before gunicorn's monkey-patching.
@gukoff proposed fix didn't work for me, I still get the same error 😞
I'm going to close this and open a discussion with the mailing list label on the R20 milestone for monkey-patching the arbiter in gevent. If you are having problems related to anything in this discussion and you think it might be a bug in Gunicorn, please open an issue. You can mention this one by number, or link to comments, if it helps add context, but at this point this is an old ticket with conversations in parallel about several versions of Gunicorn and different symptoms.
I would like to note that as of 2024, this problem persists. I encountered a similar issue at work, and the problem was resolved by removing the --reload
flag. Therefore, if you are experiencing this error and using this flag, consider deleting it as it may solve your issue :neckbeard:
Hello,
I'm seeing this error with gunicorn
19.x
(tested with19.0
and19.1.1
) using thegevent
worker. I'm usingdjango-1.7.1
.this is the exception:
Here is my
gunicorn.conf.py
:The error occurs every time, just accessing any URL of the django app (that depends on any model, of course) triggers this error. Any ideas? Since changing to
gunicorn-18.0
solves the problem, I'm assuming thatgunicorn-19.x
is doing something different.If you need any additional information, let me know and I will post it here.
For now I'm using
18.0
.Thanks a lot.