Skip to content

Commit a285564

Browse files
committed
deviceserver: force multiprocessing spawn start method in MacOSX (issue #106)
MacOSX High Sierra changed behaviour of fork in Objective-C code. +initialize methods are not supposed to be called between fork() and exec(). However, Python's multiprocessing fork start method uses fork() without exec(). Python has fixed this in version 3.8 by changing the default start method in MacOSX to spawn. This commit does the same. The workaround should be removed once we are dependent in Python 3.8 or later so that a user can easily change it to something else.
1 parent 6adf04d commit a285564

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

microscope/deviceserver.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
_logger = logging.getLogger(__name__)
4343

4444

45+
# Needed for Python<3.8 in MacOSX High Sierra (issue #106)
46+
# FIXME: remove this once we are dependent on Python>=3.8
47+
if sys.platform == 'darwin' and sys.version_info < (3,8):
48+
_logger.info("changing multiprocessing start method to 'spawn'")
49+
multiprocessing = multiprocessing.get_context('spawn')
50+
51+
4552
# Pyro configuration. Use pickle because it can serialize numpy ndarrays.
4653
Pyro4.config.SERIALIZERS_ACCEPTED.add('pickle')
4754
Pyro4.config.SERIALIZER = 'pickle'

0 commit comments

Comments
 (0)