These are chat archives for cherrypy/cherrypy

22nd
Apr 2018
Jonathan Romano
@LFP6
Apr 22 2018 18:08
Having a really weird issue on Windows. I have a very basic script:
import cherrypy

class App:
    @cherrypy.expose
    def index(self):
        return 'Done'

cherrypy.config.update({
    'server.socket_host': '127.0.0.1',
    'server.socket_port': 8080,
})

cherrypy.quickstart(App())

I run it from the command line, however when I hit CTRL+C, I get:

[22/Apr/2018:14:09:38] ENGINE Console event 0: shutting down bus
[22/Apr/2018:14:09:38] ENGINE Removed handler for console events.
[22/Apr/2018:14:09:38] ENGINE Bus STOPPING
[22/Apr/2018:14:09:43] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down
[22/Apr/2018:14:09:43] ENGINE Stopped thread 'Autoreloader'.
[22/Apr/2018:14:09:43] ENGINE Handler for console events already off.
[22/Apr/2018:14:09:43] ENGINE Stopped thread '_TimeoutMonitor'.
[22/Apr/2018:14:09:43] ENGINE Bus STOPPED
[22/Apr/2018:14:09:43] ENGINE Bus EXITING
[22/Apr/2018:14:09:43] ENGINE Waiting for child threads to terminate...
[22/Apr/2018:14:09:43] ENGINE Bus EXITED

And then it just stalls, without ending the script

On Linux:
^C[22/Apr/2018:18:07:26] ENGINE Keyboard Interrupt: shutting down bus
[22/Apr/2018:18:07:26] ENGINE Bus STOPPING
[22/Apr/2018:18:07:26] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down
[22/Apr/2018:18:07:26] ENGINE Stopped thread 'Autoreloader'.
[22/Apr/2018:18:07:26] ENGINE Stopped thread '_TimeoutMonitor'.
[22/Apr/2018:18:07:26] ENGINE Bus STOPPED
[22/Apr/2018:18:07:26] ENGINE Bus EXITING
[22/Apr/2018:18:07:26] ENGINE Bus EXITED
[22/Apr/2018:18:07:26] ENGINE Waiting for child threads to terminate...
I'm wondering if the child threads aren't actually closing right - is there something I missed in the docs? Same issue on 2.x and 3.x, quickstart and cherrypy.start/cherrypy.exit, powershell and cmd, and 11.0.0 and 14.1.0
Jason R. Coombs
@jaraco
Apr 22 2018 20:18
@LFP6: I’m not sure I understand your description. Are you saying on Linux it behaves as expected but not on Windows?
I created this command to replicate the behavior on Linux (Docker): $ echo "FROM ubuntu:xenial\nrun apt update\nrun apt install -y -q python3-pip wget\nrun python3 -m pip install cherrypy\nRUN wget https://gist.githubusercontent.com/jaraco/10bbc46157f931aefa86f33716b871c9/raw/bdb25381a2af80ca3f528a5d743f4a7ef44a7b86/gistfile1.txt -O app.py\nCMD python3 app.py" | docker build -q -
Jason R. Coombs
@jaraco
Apr 22 2018 20:23
If the issue is only on Windows, I’m afraid you’ll have to debug further - determine how these events are handled on Windows and how CherryPy manages them and why it fails. I’m pretty sure the behavior you describe is expected to work and worked at one time. You may wish to go back to even older versions of CherryPy and see if you can find a version that doesn’t have the issue.
But what you describe sounds enough like a bug, I’d start by filing a bug about it (if there isn’t one already).
Jonathan Romano
@LFP6
Apr 22 2018 22:35
@jaraco Yes, Linux works fine, but Windows stalls on ENGINE Bus EXITED and never actually ends the script running
Haven't seen a bug report, which seemed weird to me, so wanted to check first. I'll go file one