[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was ca...

最近在用python3写一个多线程工具,发现频繁报错:

objc[27880]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[27880]: +[__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.

一直以为是代码的问题,不断的检查代码,其实是macOS的High Sierra以上的操作系统对多线程的限制,别无其它原因。

临时调试方法

在终端中输入 export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

不要关闭当前终端,再次运行python程序

解决方法

打开终端 输入

cd ~
sudo vim .bash_profile

在最后一行加入

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

重启终端就解决了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容