Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #540 (defect)

Opened 2 years ago

Last modified 2 years ago

autoreload raises exception on receiving a signal

Status: closed (fixed)

Reported by: carstengrohmann@gmx.de Assigned to: rdelon
Priority: normal Milestone:
Component: CherryPy code Keywords:
Cc:

After I've send a signal to the CherryPy framework the autoreload modules raises an OSError exception.

Command to send a signal:

kill -HUP <PID>

Error message:

Traceback (most recent call last):
  File "./main.py", line 190, in ?
    start_cherrypy()
  File "./main.py", line 175, in start_cherrypy
    cherrypy.server.start()
  File "/usr/local/lib/python2.4/site-packages/cherrypy/_cpserver.py", line 72, in start
    Engine.start(self)
  File "/usr/local/lib/python2.4/site-packages/cherrypy/_cpengine.py", line 91, in start
    autoreload.main(self._start, freq=freq)
  File "/usr/local/lib/python2.4/site-packages/cherrypy/lib/autoreload.py", line 63, in main
    sys.exit(restart_with_reloader())
  File "/usr/local/lib/python2.4/site-packages/cherrypy/lib/autoreload.py", line 44, in restart_with_reloader
    exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
  File "/usr/local/lib/python2.4/os.py", line 562, in spawnve
    return _spawnvef(mode, file, args, env, execve)
  File "/usr/local/lib/python2.4/os.py", line 535, in _spawnvef
    wpid, sts = waitpid(pid, 0)
OSError: [Errno 4] Interrupted system call

Possible a try/except block will solve this problem

import errno

def restart_with_reloader():
    while True:
        args = [sys.executable] + sys.argv
        if sys.platform == "win32":
            args = ['"%s"' % arg for arg in args]
        new_environ = os.environ.copy()
        new_environ["RUN_MAIN"] = 'true'
        try:
            exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
        except OSError, e:
            if e.errno == errno.EINTR:
                continue
        if exit_code != 3:
            return exit_code

Change History

08/05/06 12:46:00: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [1211] via a signal handler. HUP now calls cherrypy.engine.reexec, and TERM calls server. and engine.stop().

12/10/06 16:59:48: Modified by fumanchu

2.x fix in [1507]. In 2.x, only SIGTERM is handled; SIGHUP is ignored because Engine has no reexec() method like in CP 3.

Hosted by WebFaction

Log in as guest/cpguest to create tickets