diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index e0c0745ab2c..f4b3ac488ab 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -83,13 +83,12 @@ import multiprocessing multiprocessing.set_start_method('fork', force=True) +from multiprocessing import Process + try: - import multiprocessing - from multiprocessing import Process + import _multiprocessing except ImportError: - multiprocessing = None - class Process: - pass + _multiprocessing = None def _sorted_dict_pprinter_factory(start, end): @@ -1490,7 +1489,7 @@ def report_failure(self, out, test, example, got, globs): except KeyboardInterrupt: # Assume this is a *real* interrupt. We need to # escalate this to the master doctesting process. - if not self.options.serial and multiprocessing: + if not self.options.serial and _multiprocessing: os.kill(os.getppid(), signal.SIGINT) raise finally: @@ -1634,7 +1633,7 @@ def report_unexpected_exception(self, out, test, example, exc_info): except KeyboardInterrupt: # Assume this is a *real* interrupt. We need to # escalate this to the master doctesting process. - if not self.options.serial and multiprocessing: + if not self.options.serial and _multiprocessing: os.kill(os.getppid(), signal.SIGINT) raise finally: @@ -2139,7 +2138,7 @@ def dispatch(self): sage -t .../sage/rings/big_oh.py [... tests, ...s wall] """ - if self.controller.options.serial or not multiprocessing: + if self.controller.options.serial or not _multiprocessing: self.serial_dispatch() else: self.parallel_dispatch()