Fix for bug 1450 high memory consumption
[osm/MON.git] / osm_mon / evaluator / evaluator.py
index d8589bb..6ca0dc5 100644 (file)
@@ -75,20 +75,30 @@ class Evaluator:
                 # Some processes have not completed due to timeout error
                 log.info('Some processes have not finished due to TimeoutError exception')
                 log.debug('concurrent.futures.TimeoutError exception %s' % (e))
-                Evaluator._stop_process_pool(executor)
+
+            # Shutting down process pool executor
+            Evaluator._stop_process_pool(executor)
 
     @staticmethod
     def _stop_process_pool(executor):
         log.debug("_stop_process_pool")
-        log.info('Stopping all processes in the process pool')
+        log.info('Shutting down process pool')
         try:
+            log.debug('Stopping residual processes in the process pool')
             for pid, process in executor._processes.items():
                 if process.is_alive():
                     process.terminate()
         except Exception as e:
             log.info("Exception during process termination")
             log.debug("Exception %s" % (e))
-        executor.shutdown()
+
+        try:
+            # Shutting down executor
+            log.debug('Shutting down process pool executor')
+            executor.shutdown()
+        except RuntimeError as e:
+            log.info('RuntimeError in shutting down executer')
+            log.debug('RuntimeError %s' % (e))
         return
 
     @staticmethod