mirror of https://github.com/python/cpython
Issue #12981: test_multiprocessing: catch ImportError when importing
multiprocessing.reduction, which may not be available (e.g. if the OS doesn't support FD passing over Unix domain sockets).
This commit is contained in:
parent
225aa4f8ec
commit
bc8f08216e
|
@ -35,7 +35,13 @@ import multiprocessing.managers
|
|||
import multiprocessing.heap
|
||||
import multiprocessing.pool
|
||||
|
||||
from multiprocessing import util, reduction
|
||||
from multiprocessing import util
|
||||
|
||||
try:
|
||||
from multiprocessing import reduction
|
||||
HAS_REDUCTION = True
|
||||
except ImportError:
|
||||
HAS_REDUCTION = False
|
||||
|
||||
try:
|
||||
from multiprocessing.sharedctypes import Value, copy
|
||||
|
@ -1631,6 +1637,7 @@ class _TestConnection(BaseTestCase):
|
|||
os.write(fd, data)
|
||||
os.close(fd)
|
||||
|
||||
@unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
|
||||
def test_fd_transfer(self):
|
||||
if self.TYPE != 'processes':
|
||||
self.skipTest("only makes sense with processes")
|
||||
|
@ -1648,6 +1655,7 @@ class _TestConnection(BaseTestCase):
|
|||
with open(test.support.TESTFN, "rb") as f:
|
||||
self.assertEqual(f.read(), b"foo")
|
||||
|
||||
@unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
|
||||
@unittest.skipIf(sys.platform == "win32",
|
||||
"test semantics don't make sense on Windows")
|
||||
@unittest.skipIf(MAXFD <= 256,
|
||||
|
@ -1987,10 +1995,12 @@ class _TestImportStar(BaseTestCase):
|
|||
'multiprocessing', 'multiprocessing.connection',
|
||||
'multiprocessing.heap', 'multiprocessing.managers',
|
||||
'multiprocessing.pool', 'multiprocessing.process',
|
||||
'multiprocessing.reduction',
|
||||
'multiprocessing.synchronize', 'multiprocessing.util'
|
||||
]
|
||||
|
||||
if HAS_REDUCTION:
|
||||
modules.append('multiprocessing.reduction')
|
||||
|
||||
if c_int is not None:
|
||||
# This module requires _ctypes
|
||||
modules.append('multiprocessing.sharedctypes')
|
||||
|
|
Loading…
Reference in New Issue