From 67c5c4e077d2d56fcabc843601f31edcb723e946 Mon Sep 17 00:00:00 2001 From: Trevor Bekolay Date: Mon, 3 Aug 2020 21:38:44 -0500 Subject: [PATCH] Use multiprocess if available On Windows, we force it to be installed as most users will need it. --- CHANGES | 3 +-- doc/cmd_run.rst | 2 ++ doit/cmd_auto.py | 5 ++++- doit/runner.py | 5 ++++- setup.py | 1 + tests/test_cmd_auto.py | 5 ++++- tests/test_runner.py | 5 ++++- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index a77c38d7..c438347f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,3 @@ - ======= Changes ======= @@ -8,6 +7,7 @@ Changes - python 3.8 support - BACKWARD INCOMPATIBLE: Drop Python 3.4 support + - support `multiprocess` and require it for Windows 0.32.0 (*2019-12-10*) @@ -527,4 +527,3 @@ Changes ==================== - initial release - diff --git a/doc/cmd_run.rst b/doc/cmd_run.rst index 5d8be54a..a4d0d374 100644 --- a/doc/cmd_run.rst +++ b/doc/cmd_run.rst @@ -240,6 +240,8 @@ parallel execution This allows different tasks to be run in parallel, as long any dependencies are met. By default the `multiprocessing `_ module is used. +If the `multiprocess `_ module is installed, +it will be used instead. So the same restrictions also apply to the use of multiprocessing in `doit`. .. code-block:: console diff --git a/doit/cmd_auto.py b/doit/cmd_auto.py index 3fbf4862..71e0a80e 100644 --- a/doit/cmd_auto.py +++ b/doit/cmd_auto.py @@ -4,7 +4,10 @@ import os import time import sys -from multiprocessing import Process +try: + from multiprocess import Process +except ImportError: + from multiprocessing import Process from subprocess import call from .exceptions import InvalidCommand diff --git a/doit/runner.py b/doit/runner.py index bcd65dbc..22eada06 100644 --- a/doit/runner.py +++ b/doit/runner.py @@ -1,6 +1,9 @@ """Task runner""" -from multiprocessing import Process, Queue as MQueue +try: + from multiprocess import Process, Queue as MQueue +except ImportError: + from multiprocessing import Process, Queue as MQueue from threading import Thread import pickle import queue diff --git a/setup.py b/setup.py index 9c7d774c..7f7a4d1b 100755 --- a/setup.py +++ b/setup.py @@ -81,6 +81,7 @@ extras_require={ ':sys.platform == "darwin"': ['macfsevents'], ':sys.platform == "linux"': ['pyinotify'], + ':sys.platform == "win32"': ['multiprocess'], }, long_description = long_description, entry_points = { diff --git a/tests/test_cmd_auto.py b/tests/test_cmd_auto.py index 9bc317aa..979390c8 100644 --- a/tests/test_cmd_auto.py +++ b/tests/test_cmd_auto.py @@ -1,5 +1,8 @@ import time -from multiprocessing import Process +try: + from multiprocess import Process +except ImportError: + from multiprocessing import Process import pytest diff --git a/tests/test_runner.py b/tests/test_runner.py index a9029e8e..11420b6a 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -1,6 +1,9 @@ import os import pickle -from multiprocessing import Queue +try: + from multiprocess import Queue +except ImportError: + from multiprocessing import Queue import platform from unittest.mock import Mock