I am having trouble running my celery task. It is a flask-based application, and the error occurs when the task attempts to run a torch model.
objc[77662]: +[NSCheapMutableString 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.
[2023-06-13 22:13:59,104: ERROR/MainProcess] Process 'ForkPoolWorker-7' pid:77662 exited with 'signal 6 (SIGABRT)'
[2023-06-13 22:13:59,123: ERROR/MainProcess] Task handler raised error: WorkerLostError('Worker exited prematurely: signal 6 (SIGABRT) Job: 0.')
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/brudatan/lib/python3.9/site-packages/billiard/pool.py", line 1264, in mark_as_worker_lost
raise WorkerLostError(
billiard.einfo.ExceptionWithTraceback:
"""
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/brudatan/lib/python3.9/site-packages/billiard/pool.py", line 1264, in mark_as_worker_lost
raise WorkerLostError(
billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 6 (SIGABRT) Job: 0.
I read that export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
may help, but it raised another WorkerLostError:
billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 9 (SIGKILL) Job: 0.
I have also tried to reinstall some packages, used celery 4.4.0, 4.4.7 and 5.3.0 but none seem to work.