Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
e7fc06221a
1 zmenil súbory, kde vykonal 5 pridanie a 4 odobranie
  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):