Browse Source

Stop catching SystemExit from subprocesses

This is tricky, but realistically the parent should be the one handling exit conditions.
Catching SystemExit swallows any intentional exit code from the child processes,
and also causes stop to be called twice in some instances. Also, there are multiple
reports of KeyboardInterrupt+multiprocessing bugs, and the guidance is to never
catch KeyboardInterrupt from child processes - let the parent process be the only
one that might catch this, and clean up properly. I don't want to make such a big change
in this pull request, so I'm leaving a note that this really needs to be changed to the
parent process catching exceptions and calling stop if needed.

[ci skip]
Hamilton Turner 11 years ago
parent
commit
d3e83cd534
1 changed files with 4 additions and 2 deletions
  1. 4 2
      toolset/benchmark/benchmarker.py

+ 4 - 2
toolset/benchmark/benchmarker.py

@@ -760,7 +760,9 @@ class Benchmarker:
         out.close()
         err.close()
         return exit_with_code(1)
-      except (KeyboardInterrupt, SystemExit) as e:
+      # TODO - subprocess should not catch this exception!
+      # Parent process should catch it and cleanup/exit
+      except (KeyboardInterrupt) as e:
         test.stop(out, err)
         out.write( """
         -----------------------------------------------------
@@ -769,7 +771,7 @@ class Benchmarker:
         """)
         out.flush()
         self.__finish()
-        sys.exit()
+        sys.exit(1)
 
       out.close()
       err.close()