Skip to content

Commit

Permalink
More autoreloader fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Feb 23, 2012
1 parent 8058082 commit 439a566
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions celery/utils/threads.py
Expand Up @@ -39,17 +39,17 @@ def __init__(self, name=None, **kwargs):
def body(self):
raise NotImplementedError("subclass responsibility")

def on_crash(self, msg, *fmt, **kwargs):
def on_crash(self, exc_info, msg, *fmt, **kwargs):
sys.stderr.write((msg + "\n") % fmt)
traceback.print_stack(file=sys.stderr)
traceback.print_exception(*exc_info, file=sys.stderr)

def run(self):
shutdown = self._is_shutdown
while not shutdown.is_set():
try:
self.body()
except Exception, exc:
self.on_crash("%r crashed: %r", self.name, exc, exc_info=True)
self.on_crash(sys.exc_info(), "%r crashed: %r", self.name, exc)
# exiting by normal means does not work here, so force exit.
os._exit(1)
try:
Expand Down
6 changes: 4 additions & 2 deletions celery/worker/autoreload.py
Expand Up @@ -39,7 +39,6 @@ def __init__(self, w, autoreload=None, **kwargs):
def create(self, w):
w.autoreloader = self.instantiate(w.autoreloader_cls,
controller=w,
modules=w.autoreload,
logger=w.logger)
return w.autoreloader

Expand Down Expand Up @@ -194,6 +193,8 @@ def __init__(self, controller, modules=None, monitor_cls=None,
self.logger = logger
self.options = options
self.Monitor = monitor_cls or self.Monitor
self._monitor = None
self._hashes = None

def body(self):
files = [sys.modules[m].__file__ for m in self.modules]
Expand Down Expand Up @@ -224,7 +225,8 @@ def _reload(self, modules):
self.controller.reload(modules, reload=True)

def stop(self):
self._monitor.stop()
if self._monitor:
self._monitor.stop()

@staticmethod
def _module_name(path):
Expand Down

0 comments on commit 439a566

Please sign in to comment.