From 95da83d9bac698d420cc308e8699ef6e4fae2aca Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 13 May 2019 20:02:46 +0200 Subject: [PATCH] bpo-36894: Fix regression in test_multiprocessing_spawn (no tests run on Windows) (GH-13290) --- Lib/multiprocessing/resource_tracker.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Lib/multiprocessing/resource_tracker.py b/Lib/multiprocessing/resource_tracker.py index e67e0b213eb..61a6dd66e72 100644 --- a/Lib/multiprocessing/resource_tracker.py +++ b/Lib/multiprocessing/resource_tracker.py @@ -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):