Jelajahi Sumber

Update loggers.py

If the active log file (at least stdout-log for a supervised proccess) is removed, the log file will not be recreated. When loggers.py tries to do "os.rename(self.baseFilename, dfn)" in RotatingFileHandler.removeAndRename (called by RotatingFileHandler.doRollover) it will fail with OSError, no new file is opened, and the managed process will later be stuck in a write.

It's not uncommon with cleanup scripts in /tmp, and /tmp is the default location for the logs...
Magnus Lyckå 11 tahun lalu
induk
melakukan
16b46ac019
1 mengubah file dengan 8 tambahan dan 2 penghapusan
  1. 8 2
      supervisor/loggers.py

+ 8 - 2
supervisor/loggers.py

@@ -190,10 +190,16 @@ class RotatingFileHandler(FileHandler):
             try:
                 os.remove(dfn)
             except OSError, why:
-                # catch race condition (already deleted)
+                # catch race condition (destination already deleted)
                 if why.args[0] != errno.ENOENT:
                     raise
-        os.rename(sfn, dfn)
+        try:
+            os.rename(sfn, dfn)
+        except OSError, why:
+            # catch exceptional condition (source deleted)
+            # E.g. cleanup script removes active log.
+            if why[0] != errno.ENOENT:
+                raise
 
     def doRollover(self):
         """