in DevOps

MacOSX Python multiprocessing crash with fork error

Error:

objc[67390]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[67390]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

 

Fix:

This error occurs because of added security to restrict multithreading in Mac OSX since version High Sierra.

To fix the issue Set an environment variable .bash_profile to allow multithreading applications or scripts under the new Mac OS security rules.

Open a terminal:

$ nano .bash_profile

Add the following line to the end of the file:

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

Save, exit, close terminal and re-open the terminal. Check to see that the environment variable is now set. You should now be able to run your python script with multithreading.