Przeglądaj źródła

Autoreload now works if module.__file__ is a .pyc. Closes #647

Ask Solem 13 lat temu
rodzic
commit
91e8ae6c44
2 zmienionych plików z 7 dodań i 1 usunięć
  1. 5 0
      celery/utils/__init__.py
  2. 2 1
      celery/worker/autoreload.py

+ 5 - 0
celery/utils/__init__.py

@@ -457,3 +457,8 @@ def maybe_reraise():
     finally:
         # see http://docs.python.org/library/sys.html#sys.exc_info
         del(tb)
+
+
+def module_file(module):
+    name = module.__file__
+    return name[:-1] if name.endswith(".pyc") else name

+ 2 - 1
celery/worker/autoreload.py

@@ -18,6 +18,7 @@ import time
 from collections import defaultdict
 
 from ..abstract import StartStopComponent
+from ..utils import module_file
 from ..utils.threads import bgThread, Event
 
 try:
@@ -211,7 +212,7 @@ class Autoreloader(bgThread):
         self._hashes = None
 
     def body(self):
-        files = [sys.modules[m].__file__ for m in self.modules]
+        files = [module_file(sys.modules[m]) for m in self.modules]
         self._monitor = self.Monitor(files, self.on_change,
                 shutdown_event=self._is_shutdown, **self.options)
         self._hashes = dict([(f, file_hash(f)) for f in files])