nvie/rq — pull request #63 by selwin (2012-05-08 09:54:39+00:00)
Title: Error when running ``Worker`` with explicit ``connection`` argument

Hi there,

I ran into this error when trying to run ``Worker`` without using ``use_connection``:

>>> import redis
>>> from rq import Queue, Worker
>>>
>>> connection = redis.Redis(host='localhost', port=6379, db=0)
>>> queue = Queue(connection=connection)
>>> w = Worker(queue, connection=connection)
>>> w.work()
[2012-05-08 09:51] DEBUG: worker: Registering birth of worker selwin.10282
[2012-05-08 09:51] INFO: worker:
[2012-05-08 09:51] INFO: worker: *** Listening on ^[[32mdefault^[[39;49;00m...
[2012-05-08 09:51] DEBUG: worker: Registering death
Traceback (most recent call last):
File "", line 1, in
File "/home/selwin/dev/pencerah/libraries/rq/worker.py", line 278, in work
connection=self.connection)
File "/home/selwin/dev/pencerah/libraries/rq/queue.py", line 208, in dequeue_any
result = cls.lpop(queue_keys, blocking)
File "/home/selwin/dev/pencerah/libraries/rq/queue.py", line 168, in lpop
queue_key, job_id = conn.blpop(queue_keys)
AttributeError: 'NoneType' object has no attribute 'blpop'

Attached is a pull request that I think fixes the problem. All tests pass.