Browse Source

celery crashes on git pull

If tasks.py file is modified in git repository and I run git pull on server, then celery crashes.

"Git pull" first removes the file and then restores it, but pyinotify catches removal event.

I updated _maybe_modified function to first verify if file exists and if not then mark file as "unmodified", because afterwards will be another event when file is recreated.
Agris Ameriks 12 năm trước cách đây
mục cha
commit
e7fc06221a
1 tập tin đã thay đổi với 5 bổ sung4 xóa
  1. 5 4
      celery/worker/autoreload.py

+ 5 - 4
celery/worker/autoreload.py

@@ -251,10 +251,11 @@ class Autoreloader(bgThread):
             self._monitor.start()
 
     def _maybe_modified(self, f):
-        digest = file_hash(f)
-        if digest != self._hashes[f]:
-            self._hashes[f] = digest
-            return True
+        if os.path.exists(f):
+            digest = file_hash(f)
+            if digest != self._hashes[f]:
+                self._hashes[f] = digest
+                return True
         return False
 
     def on_change(self, files):