bpo-36894: Fix regression in test_multiprocessing_spawn (no tests run on Windows...
authorAntoine Pitrou <antoine@python.org>
Mon, 13 May 2019 18:02:46 +0000 (20:02 +0200)
committerGitHub <noreply@github.com>
Mon, 13 May 2019 18:02:46 +0000 (20:02 +0200)
Lib/multiprocessing/resource_tracker.py

index e67e0b213eb948a6ba825ea740cbc80dabbe4170..61a6dd66e72e67ec433218a1755175ebae7f4656 100644 (file)
@@ -20,8 +20,6 @@ import signal
 import sys
 import threading
 import warnings
-import _multiprocessing
-import _posixshmem
 
 from . import spawn
 from . import util
@@ -33,10 +31,17 @@ _IGNORED_SIGNALS = (signal.SIGINT, signal.SIGTERM)
 
 _CLEANUP_FUNCS = {
     'noop': lambda: None,
-    'semaphore': _multiprocessing.sem_unlink,
-    'shared_memory': _posixshmem.shm_unlink
 }
 
+if os.name == 'posix':
+    import _multiprocessing
+    import _posixshmem
+
+    _CLEANUP_FUNCS.update({
+        'semaphore': _multiprocessing.sem_unlink,
+        'shared_memory': _posixshmem.shm_unlink,
+    })
+
 
 class ResourceTracker(object):