Parcourir la 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 il y a 12 ans
Parent
commit
e7fc06221a
1 fichiers modifiés avec 5 ajouts et 4 suppressions
  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):