CherryPy server getting CTRL-C?

828 views
Skip to first unread message

Joril

unread,
Jan 29, 2013, 4:04:48 AM1/29/13
to cherryp...@googlegroups.com
Hi everyone!
I have a CherryPy-based server running as an Upstart service. It works nicely most of the time, but sometimes it shuts down by itself (I think), here's an example of what the log shows:

[HTTPServer Thread-2] cherrypy/__init__.py _buslog:321  - [29/Jan/2013:09:06:30] ENGINE <Ctrl-C> hit: shutting down HTTP server
[HTTPServer Thread-2] cherrypy/__init__.py _buslog:321  - [29/Jan/2013:09:06:30] ENGINE Bus STOPPING
[HTTPServer Thread-2] cherrypy/__init__.py _buslog:321  - [29/Jan/2013:09:06:30] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8087)) shut down
[HTTPServer Thread-2] cherrypy/__init__.py _buslog:321  - [29/Jan/2013:09:06:30] ENGINE Stopped thread '_TimeoutMonitor'.
[HTTPServer Thread-2] cherrypy/__init__.py _buslog:321  - [29/Jan/2013:09:06:30] ENGINE Bus STOPPED
[HTTPServer Thread-2] cherrypy/__init__.py _buslog:321  - [29/Jan/2013:09:06:30] ENGINE Bus EXITING
[HTTPServer Thread-2] cherrypy/__init__.py _buslog:321  - [29/Jan/2013:09:06:30] ENGINE Bus EXITED
[MainThread] cherrypy/__init__.py _buslog:321   - [29/Jan/2013:09:06:30] ENGINE Waiting for child threads to terminate...

I cannot understand why this is happening... How could a background service receive a KeyboardInterrupt?

(CherryPy 3.2.2 on Python 2.7.3 on Ubuntu 12.04)

Joel Rivera

unread,
Jan 29, 2013, 1:14:50 PM1/29/13
to cherryp...@googlegroups.com
Hi Joril.

The KeyboardInterrupt is just a way to say that the process has received
a SIGINT signal, which can came from any other place, not just the
keyboard [1].

For example

cherryd -p /tmp/cherry.pid # start an empty cherrypy server

and in another terminal:

kill -s INT `</tmp/cherry.pid` # send SIGINT to the process.

You will see the same message of "Keyboard Interrupt: shutting down
bus".

I hope that clarify the issue.

Cheers.

[1] : http://en.wikipedia.org/wiki/SIGINT_%28POSIX%29#SIGINT
> --
> You received this message because you are subscribed to the Google
> Groups "cherrypy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to cherrypy-user...@googlegroups.com.
> To post to this group, send email to cherryp...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/cherrypy-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Rivera²

Joril

unread,
Jan 30, 2013, 2:48:13 AM1/30/13
to cherryp...@googlegroups.com
On Tuesday, January 29, 2013 7:14:50 PM UTC+1, Joel Rivera wrote:
Hi Joril.

The KeyboardInterrupt is just a way to say that the process has received
a SIGINT signal, which can came from any other place, not just the
keyboard [1].
 
I see, but I can't figure how what could be sending a SIGINT... I'll try to investigate further, thanks!

Joril

unread,
Feb 5, 2013, 10:01:57 AM2/5/13
to cherryp...@googlegroups.com
On Wednesday, January 30, 2013 8:48:13 AM UTC+1, Joril wrote:
The KeyboardInterrupt is just a way to say that the process has received
a SIGINT signal, which can came from any other place, not just the
keyboard [1].


I've set up a SIGINT handler like this

def handle_sigint():
    logger.log("SIGINT catched")
cherrypy.engine.signal_handler.handlers["SIGINT"] = handle_sigint

and it works if I kill -SIGINT the server.

Sadly the server crashed again today with the same "CTRL-C hit" message, but I cannot find any "SIGINT catched" inside the log... Am I missing something?

Eric Larson

unread,
Feb 5, 2013, 11:47:19 AM2/5/13
to cherryp...@googlegroups.com
Are you running it on a shared host? Your host may not allow long
running processes, which case it might be periodically cleaning up any
long running scripts it finds.

Just a thought!

Eric

Joril

unread,
Feb 5, 2013, 12:14:06 PM2/5/13
to cherryp...@googlegroups.com
I think I've found the culprit, logged inside /var/log/upstart/myapp.log... Exactly before every "CTRL-C hit" there's a "maximum recursion depth exceeded" from a method of mine that's called only sometimes. (This wasn't logged in my normal application log)
It's strange though, why would something like this be handled by CherryPy as a KeyboardException?

Reply all
Reply to author
Forward
0 new messages