Warning when gunicorn restarts worker

468 views
Skip to first unread message

jesper

unread,
Mar 11, 2020, 5:48:03 AM3/11/20
to cherrypy-users
Hi CherryPy users,

I run a CherryPy WSGI application using gunicorn. But when I let gunicorn restart workers after some requests I get a RuntimeWarning:

$ gunicorn --bind 0.0.0.0:9090 --max-requests 1 wsgi_test
[2020-03-11 10:42:21 +0100] [11524] [INFO] Starting gunicorn 19.10.0
[2020-03-11 10:42:21 +0100] [11524] [INFO] Listening at: http://0.0.0.0:9090 (11524)
[2020-03-11 10:42:21 +0100] [11524] [INFO] Using worker: sync
[2020-03-11 10:42:21 +0100] [11529] [INFO] Booting worker with pid: 11529
[11/Mar/2020:10:42:21] ENGINE Bus STARTING
[11/Mar/2020:10:42:21] ENGINE Bus STARTED
[2020-03-11 10:42:23 +0100] [11529] [INFO] Autorestarting worker after current request.
127.0.0.1 - - [11/Mar/2020:10:42:23] "GET /status HTTP/1.1" 200 17 "" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0"
[2020-03-11 10:42:23 +0100] [11529] [INFO] Worker exiting (pid: 11529)
/home/jbl/.local/lib/python3.6/site-packages/cherrypy/process/wspbus.py:258: RuntimeWarning: The main thread is exiting, but the Bus is in the states.STARTED state; shutting it down automatically now. You must either call bus.block() after start(), or call bus.exit() before the main thread exits.
 
'main thread exits.' % self.state, RuntimeWarning)
[11/Mar/2020:10:42:23] ENGINE Bus STOPPING
[11/Mar/2020:10:42:23] ENGINE Bus STOPPED
[11/Mar/2020:10:42:23] ENGINE Bus EXITING
[11/Mar/2020:10:42:23] ENGINE Bus EXITED
[2020-03-11 10:42:23 +0100] [11531] [INFO] Booting worker with pid: 11531
[11/Mar/2020:10:42:23] ENGINE Bus STARTING
[11/Mar/2020:10:42:23] ENGINE Bus STARTED

Here is the test app that I run:

# encoding: utf-8
import cherrypy

cherrypy
.config.update({'engine.autoreload.on': False})
cherrypy
.server.unsubscribe()
cherrypy
.engine.start()


class TestApp(object):
   
def __init__(self):
       
pass

   
@cherrypy.expose
   
def status(self):
       
return 'Server is RUNNING'


application
= cherrypy.Application(TestApp())

Do I need to do something to make it shut down the Hunicorn worker properly?

I believe Gunicorn is sending these signals to the worker: https://docs.gunicorn.org/en/stable/signals.html#worker-process


jesper

unread,
Mar 11, 2020, 5:49:00 AM3/11/20
to cherrypy-users
*Hunicorn -> Gunicorn
Reply all
Reply to author
Forward
0 new messages