Issue #540 resolved

autoreload raises exception on receiving a signal

Anonymous created an issue

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: {{{

!python

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 }}}

Reported by carstengrohmann@gmx.de

Comments (3)

  1. Log in to comment