Reputation: 33
I have the following code:
@job
def create_model():
test_text = "Text1"
TestModel.objects.create(test_text=test_text)
print("Done!")
def test_view(request):
create_model.delay()
return HttpResponse("Ok!")
But this produces weird errors in console:
(venv) ➜ DjangoRedisQueueTest python manage.py rqworker
08:58:01 Worker rq:worker:e95d3ce3ab82415cb5f9b1eb8dbdad72 started with PID 30490, version 1.16.1
08:58:01 Subscribing to channel rq:pubsub:e95d3ce3ab82415cb5f9b1eb8dbdad72
08:58:01 *** Listening on default...
08:58:01 Cleaning registries for queue: default
08:58:04 default: drq_test.views.create_model() (f3701c9e-63df-42aa-9dd6-5169892c644c)
objc[30495]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[30495]: +[__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.
08:58:04 Moving job to FailedJobRegistry (Work-horse terminated unexpectedly; waitpid returned 6 (signal 6); )
How can I use django RQ to delay such tasks like saving models to the database
Upvotes: 1
Views: 33