I am trying to execute a function through rq worker. This is the error i get:
objc[4463]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[4463]: +[__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.
16:35:40 Moving job to FailedJobRegistry (work-horse terminated unexpectedly; waitpid returned 6)
This is how I am adding the task in the queue. It is Fast Api route
r=RedisQueue.get_redis()
q=Queue(connection=r)
job=q.enqueue(export_testcases_to_xlsx,testcases,token)
RedisQueue.get_worker(r)
I have a redisqueue.py file which is like this:
import redis
from rq import Queue,Connection,Worker
from rq.job import Job
from app.model.Settings import Settings
import sys,os
settings=Settings()
class RedisQueue:
@staticmethod
def get_redis():
# To run on container
if settings.redis_host:
r = redis.Redis(host=settings.redis_host, port=settings.redis_port)
# To run locally
else:
r = redis.Redis()
return r
def get_worker(r):
listen = ['default']
with Connection(r):
worker = Worker(list(map(Queue, listen)))
worker.work()
When I don't start the worker through the get_worker function and directly use rq worker command in the terminal to start the worker it is working fine.