diff options
Diffstat (limited to 'rq')
-rw-r--r-- | rq/__init__.py | 2 | ||||
-rw-r--r-- | rq/connections.py | 20 |
2 files changed, 3 insertions, 19 deletions
diff --git a/rq/__init__.py b/rq/__init__.py index d5db681..ec635d7 100644 --- a/rq/__init__.py +++ b/rq/__init__.py @@ -1,6 +1,6 @@ # flake8: noqa -from .connections import Connection, get_current_connection, pop_connection, push_connection, use_connection +from .connections import Connection, get_current_connection, pop_connection, push_connection from .job import cancel_job, get_current_job, requeue_job, Retry from .queue import Queue from .version import VERSION diff --git a/rq/connections.py b/rq/connections.py index 413ee5a..2c6d227 100644 --- a/rq/connections.py +++ b/rq/connections.py @@ -3,7 +3,7 @@ from typing import Optional import warnings from redis import Redis -from .local import LocalStack, release_local +from .local import LocalStack class NoRedisConnectionException(Exception): @@ -65,22 +65,6 @@ def pop_connection() -> 'Redis': return _connection_stack.pop() -def use_connection(redis: Optional['Redis'] = None): - """ - Clears the stack and uses the given connection. Protects against mixed - use of use_connection() and stacked connection contexts. - - Args: - redis (Optional[Redis], optional): A Redis Connection. Defaults to None. - """ - assert len(_connection_stack) <= 1, 'You should not mix Connection contexts with use_connection()' - release_local(_connection_stack) - - if redis is None: - redis = Redis() - push_connection(redis) - - def get_current_connection() -> 'Redis': """ Returns the current Redis connection (i.e. the topmost on the @@ -118,4 +102,4 @@ def resolve_connection(connection: Optional['Redis'] = None) -> 'Redis': _connection_stack = LocalStack() -__all__ = ['Connection', 'get_current_connection', 'push_connection', 'pop_connection', 'use_connection'] +__all__ = ['Connection', 'get_current_connection', 'push_connection', 'pop_connection'] |