Browse Source

pipe semaphore

justheuristic 4 years ago
parent
commit
a8610f9988
1 changed files with 12 additions and 6 deletions
  1. 12 6
      examples/albert/run_trainer.py

+ 12 - 6
examples/albert/run_trainer.py

@@ -35,14 +35,20 @@ def analyze_openfiles_periodically():
         logger.info(f"Scanning open files for process {psutil.Process().pid}")
         children = [psutil.Process()] + psutil.Process().children(recursive=True)
         for child in children:
-            open_files = child.open_files()
-            logger.info(f"proc: '{child.name()}' pid={child.pid} parent={child.parent().pid} files: {len(open_files)}")
+            try:
+                num_open_files = len(child.open_files())
+            except:
+                num_open_files = "FAILED"
+            logger.info(f"proc: '{child.name()}' pid={child.pid} parent={child.parent().pid} files: {num_open_files}")
         for child in children:
-            open_files = child.open_files()
-            if len(open_files) > 100:
-                logger.info(f"proc: {child.name()} has {len(open_files)} open files: {repr(open_files)}")
+            try:
+                open_files = child.open_files()
+                if len(open_files) > 100:
+                    logger.info(f"proc: {child.name()} has {len(open_files)} open files: {repr(open_files)}")
+            except:
+                pass
         logger.info("DONE scanning")
-        time.sleep(30)
+        time.sleep(300)
 
 
 analyzer = threading.Thread(target=analyze_openfiles_periodically)