Explorar o código

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 %!s(int64=12) %!d(string=hai) anos
pai
achega
e7fc06221a
Modificáronse 1 ficheiros con 5 adicións e 4 borrados
  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):