Add simple helper function, to avoid users to learn about the `conn`

stack.

This makes it easier to start using the product.
This commit is contained in:
Vincent Driessen 2011-11-17 13:29:32 +01:00
parent 0ff2984adf
commit a491ff248d
1 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,13 @@
from redis import Redis
from .proxy import conn from .proxy import conn
from .queue import Queue from .queue import Queue
from .worker import Worker from .worker import Worker
__all__ = ['conn', 'Queue', 'Worker'] def use_redis(redis=None):
if redis is None:
redis = Redis()
elif not isinstance(redis, Redis):
raise TypeError('Argument redis should be a Redis instance.')
conn.push(redis)
__all__ = ['conn', 'Queue', 'Worker', 'use_redis']