bretth / django-pq

[UNMAINTAINED] A task queue based on the elegant python RQ but with a django postgresql backend.
BSD 2-Clause "Simplified" License
68 stars 7 forks source link

AttributeError: 'Queue' object has no attribute 'acquire_lock' #2

Closed jurecuhalev closed 11 years ago

jurecuhalev commented 11 years ago

Nice project, just perfect for what I was looking for. You might be faster in knowing what's going on. When using pqworker with SerialQueue, it throws error:

AttributeError: 'Queue' object has no attribute 'acquire_lock'

I think the problem is in queue.py, line 331:

            if q.serial and not q.acquire_lock(timeout):

I'm just following readme for now:

from pq import SerialQueue
q = SerialQueue('serial')
q.enqueue_call(my_call)

I'll try to figure out if I can provide more debug info, I'm not yet sure how your classes exactly interact.

bretth commented 11 years ago

Ahh thanks. I can see how this would occur. If you had already created a serial queue q = SerialQueue() and then a regular queue q = Queue() they would in fact be the same queue (default) and q.serial would be True and then passing that default queue to the worker w = Worker(q) would cause that error.

bretth commented 11 years ago

You can workaround by ensuring the names are distinct and that your ordinary queues are not already created on django with q.serial=True. Just q.serial=False and then q.save()

bretth commented 11 years ago

Pushed up a new version to pypi with that fix.

jurecuhalev commented 11 years ago

Thank you. Fix works great.

bretth commented 11 years ago

Hmm I was in too much of a hurry. I need to fix for the management command as well otherwise it won't ever actually do the serial jobs.

bretth commented 11 years ago

Ok better now..