This is bugging me for past few hours and I can not seem to find a solution yet.
I am using django-rq to enqueue some long running tasks. In my tasks.py
, I have the following:
from django_rq import job
@job
def long_running_task(hash, url, file_path):
#doing some work
and in my views.py
,
def post(self, request, hash, file_path, format=None):
URL = "http://127.0.0.1:9000/work/"
task = django_rq.enqueue(long_running_task, hash, URL, file_path)
print("job result is: ", task.result)
return JsonResponse({"task_result": task.result})
When I run it, however, it fails with the following message-
TypeError: long_running_task() takes 2 positional arguments but 3 were given
Clearly, I am doing something silly here, but I am not able to figure it out yet. Can someone please let me know what's going on here?
Strangely, this seemed to be a circular dependency type of issue. Previously, I had the tasks.py
file (where I defined the long_running_task
) one level up from my views.py
file. I moved the tasks.py
file to the same level and it started working fine. No idea though as to why the seemingly unrelated error was being thrown.