可搜索,可注册,可登录,致敬逗比大佬!尽在救援版逗比根据地 dbgjd.com
投稿文章 | 广告合作 | Telegram 群组 / 公告频道 / 使用教程

+[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. 解决方法

News felisharhoads92 560℃ 0评论

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

1
2
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程序

解决方法

打开终端 输入

1
2
cd ~
sudo vim .bash_profile

在最后一行加入

1
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

重启终端就解决了。


转载请注明:逗比根据地 » +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. 解决方法

喜欢 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址