summaryrefslogtreecommitdiff
path: root/rq
diff options
context:
space:
mode:
authorlowercase00 <21188280+lowercase00@users.noreply.github.com>2023-03-07 00:54:47 -0300
committerGitHub <noreply@github.com>2023-03-07 10:54:47 +0700
commitd5bde117c2f5477b5d0ba9846f2a7c4480ca1854 (patch)
tree7e43df189b474787860ade15c0f865055b8a0a85 /rq
parent7f9f0f72ba1adac907791d604d5f56af8125fdfd (diff)
downloadrq-d5bde117c2f5477b5d0ba9846f2a7c4480ca1854.tar.gz
Remove `use_connection` (#1859)
* feat: remove use_connection * fix: clear old test
Diffstat (limited to 'rq')
-rw-r--r--rq/__init__.py2
-rw-r--r--rq/connections.py20
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']