I'm having this error when calling my function start and using the multiprocessing module on Python 2.7.8 . I'm using a mac OS 10.9.5.
The process has forked and you cannot use this CoreFoundation functionality safely.
You MUST exec(). Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_
COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
Here is the code, under the classe Lattice. My function sansfin is working well and is returning a boolean, it only take as an argument self and an integer to loop on.
def start(self):
if __name__ == '__main__':
self.run = True
p = Process(target=self.sansfin, args=(1000,))
p.start()
p.join()
def stop(self):
self.run = False
I am quite lost with this message. I don't have found anything helpful there and elsewhere. Some are suggesting a bug ...
To fix this error, you need to explicitly set the multiprocessing
start method to spawn
on MacOS. This can be achieved by adding the following immediately below if __name__ == '__main__'
. For example:
import platform, multiprocessing
...
if __name__ == '__main__':
if platform.system() == "Darwin":
multiprocessing.set_start_method('spawn')
See Also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With