Skip to content

Commit

Permalink
handle a crash via broken pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Mar 11, 2019
1 parent c67e2bd commit e23db1e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
unreleased
==========

- If the worker crashes immediately, sometimes ``hupper`` would go into a
restart loop instead of waiting for a code change.
See https://github.com/Pylons/hupper/pull/50

1.6 (2019-03-06)
================

Expand Down
24 changes: 20 additions & 4 deletions src/hupper/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,26 @@ def _run_worker(self):
continue

if cmd is None:
self.logger.info(
'Broken pipe to server, triggering a reload.'
)
force_restart = True
if worker.is_alive():
# the worker socket has died but the process is still
# alive (somehow) so wait a brief period to see if it
# dies on its own - if it does die then we want to
# treat it as a crash and wait for changes before
# reloading, if it doesn't die then we want to force
# reload the app immediately because it probably
# didn't die due to some file changes
time.sleep(self.reload_interval)

if worker.is_alive():
self.logger.info(
'Broken pipe to server, triggering a reload.'
)
force_restart = True

else:
self.logger.debug(
'Broken pipe to server, looks like a crash.'
)
break

if cmd[0] == 'reload':
Expand Down

0 comments on commit e23db1e

Please sign in to comment.