django-q icon indicating copy to clipboard operation
django-q copied to clipboard

async_iter fails at signing executed tasks

Open sistason opened this issue 8 years ago • 3 comments

async_ = Iter(recognize) async_.append(1) async_.run()

This always leads to a

[Q] ERROR No ":" found in value which is raised by the core.signing module in the unsign-method. I found out the task is successfully signed by django, unsigned by django-q, processed, but then django cannot unsign the result as it is not (correctly) signed by django-q, it is just None.

It only appears when using Iter/async_iter, so only when using groups, the same tasks work when using async(). async_iter(sync=True) also works.

sistason avatar Aug 22 '17 12:08 sistason

@sistason I believe you and @anroopak (#250) are experiencing the same issue. Can you check if this problem is still present in the latest version of Django Q

Eagllus avatar Feb 06 '18 15:02 Eagllus

This problem is still present on DjangoQ 1.2.1. I'm running Django 3.0.3 and Python 3.7.6.

The same task works when using async_task. Also, the result of the jobs are actually correct, but the task itself seems to fail badly, because it's not even saved to the django_q_task table.

Any ideas on how to fix it?

hannonq avatar Apr 07 '20 17:04 hannonq

I had the same problem. After tracing through Django Q, I found that this problem is caused by using the default caching settings. When that happens, this line in the queue server will fail:

task["args"] = SignedPackage.loads(broker.cache.get(group_args))`

This will get the arguments for the iter from the cache. But since the default cache is a local memory cache, the Django server will write the arguments of the iter to a different cache than the cache used by the Django Q server. Because of this, the cache will return None, and SignedPackage.loads fails with the error No ":" found in value.

You need to configure a cache backend which is shared between Django and the queue server, such as django-redis. Here's an example: https://realpython.com/caching-in-django-with-redis/

Not necessarily a bug in Django Q, but a horribly confusing error message. It could be improved by adding a check that the return value of broker.cache.get(group_args) is not None, and raising a more specific error message.

nickodell avatar Oct 08 '21 21:10 nickodell