錯誤提示並且報pycharm異常退出
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以上的操作系統對多線程的限制
解決辦法
1、在終端運行代碼之前 export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES 臨時解決
2、 sudo echo "export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> ~/.bash_profile && source ~/.bash_profile 長久解決
但是這個加上去之后我寫的flask接口會報錯,導入猴子包就ok
if __name__ == "__main__":
from gevent import monkey
monkey.patch_all()
app.run(debug=True, host='0.0.0.0', port=5000)
3、 打開pycharm



完美解決!!!!
