From a491ff248d2195e3ef72bc39e0d9e834005d62ba Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 17 Nov 2011 13:29:32 +0100 Subject: [PATCH] Add simple helper function, to avoid users to learn about the `conn` stack. This makes it easier to start using the product. --- rq/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rq/__init__.py b/rq/__init__.py index 07f3a396..ed309b30 100644 --- a/rq/__init__.py +++ b/rq/__init__.py @@ -1,5 +1,13 @@ +from redis import Redis from .proxy import conn from .queue import Queue 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']