Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. #542

Open
Ebrahimhammad opened this issue Jul 4, 2022 · 6 comments

Comments

@Ebrahimhammad
Copy link

Hi all,

issue is below:

objc[8104]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[8104]: +[__NSCFConstantString 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.
14:35:46 Moving job to FailedJobRegistry (work-horse terminated unexpectedly; waitpid returned 6)

After a little research, it seems specifically related to macOS. I am using it on production on Ubuntu server and it is working fine.

But on my local machine, macOS, this error showing up.

.. now this error is showing when I am trying to send a message through Twilio.

I am not sure now if this caused by Twilio or Django-rq ?

Thank you

@poitch
Copy link

poitch commented Jul 13, 2022

I'm seeing the same issue on MacOS 12.4
% python --version
Python 3.10.5

I am not using Twilio.

I have had this issue on MacOS since 2020 personally and was never able to use django-rq for my local development environment.

@selwin
Copy link
Collaborator

selwin commented Nov 6, 2022

@poitch can you try to reproduce this locally and send a few stack traces? Also, does Django RQ's test suite runs on your local development environment?

@selwin
Copy link
Collaborator

selwin commented Nov 6, 2022

This issue may be related to #375 @poitch @Ebrahimhammad . Have you tried changing the worker class to SimpleWorker (does not call os.fork()) and see if it works?

@a-toms
Copy link

a-toms commented Nov 25, 2022

Had the same problem on M1 mac.

Fix: Set an env var in your terminal.
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

Description: rails/rails#38560 (comment)

@adamghill
Copy link

Have you tried changing the worker class to SimpleWorker (does not call os.fork()) and see if it works?

I have the same issue as the OP on my M1 Mac. I tried to using SimpleWorker with this in my settings:

RQ = {"WORKER_CLASS": "rq.SimpleWorker"}

That prevented the error from happening.

Running the worker with OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES python manage.py rqworker also seems to work.

@ramsondon
Copy link

OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YESfixed the problem for python.3.11 django 4.2.11, celery 5.3.4

when trying to start a delayed shared_task from a management command by another terminal process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants