Commits

sbt committed 58bf6be Draft

Try to fix spawn start method on platforms without SCM_RIGHTS support

  • Participants
  • Parent commits 118b301
  • Branches spawn

Comments (0)

Files changed (3)

File Lib/multiprocessing/popen_forkserver.py

 
 __all__ = ['PopenForkServer', 'forkserver_helper']
 
+
+if not (hasattr(socket, 'CMSG_LEN') and hasattr(socket, 'SCM_RIGHTS')):
+    raise ImportError('No support for sending fds between processes')
+
 #
 # Start child process using a server process
 #

File Lib/multiprocessing/reduction.py

 #
 #
 
-if not(sys.platform == 'win32' or (hasattr(socket, 'CMSG_LEN') and
-                                   hasattr(socket, 'SCM_RIGHTS'))):
-    raise ImportError('pickling of connections not supported')
+HAVE_SEND_HANDLE = not(sys.platform == 'win32' or
+                       (hasattr(socket, 'CMSG_LEN') and
+                        hasattr(socket, 'SCM_RIGHTS')))
 
 #
 # Platform specific definitions

File Lib/test/test_multiprocessing.py

 
 try:
     from multiprocessing import reduction
-    HAS_REDUCTION = True
+    HAS_REDUCTION = reduction.HAVE_SEND_HANDLE
 except ImportError:
     HAS_REDUCTION = False
 
     if sys.argv[1:] == ['--spawn']:
         multiprocessing.set_start_method('spawn')
     elif sys.argv[1:] == ['--forkserver']:
+        if not HAS_REDUCTION:
+            raise unittest.SkipTest('do not have SCM_RIGHTS support')
         multiprocessing.set_start_method('forkserver')
     elif sys.argv[1:] == ['--fork']:
         multiprocessing.set_start_method('fork')