summaryrefslogtreecommitdiff
path: root/rq
diff options
context:
space:
mode:
authorlowercase00 <21188280+lowercase00@users.noreply.github.com>2023-03-07 23:37:39 -0300
committerGitHub <noreply@github.com>2023-03-08 09:37:39 +0700
commitc12561db0a16156d991774181680616fc31f9b54 (patch)
tree2b8dfa03ee2de0274d700d8955bcda71e18583ec /rq
parentd5bde117c2f5477b5d0ba9846f2a7c4480ca1854 (diff)
downloadrq-c12561db0a16156d991774181680616fc31f9b54.tar.gz
docs: add deprecation warnings to connection functions (#1860)
Diffstat (limited to 'rq')
-rw-r--r--rq/connections.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/rq/connections.py b/rq/connections.py
index 2c6d227..792eb4f 100644
--- a/rq/connections.py
+++ b/rq/connections.py
@@ -1,6 +1,7 @@
+import warnings
from contextlib import contextmanager
from typing import Optional
-import warnings
+
from redis import Redis
from .local import LocalStack
@@ -31,7 +32,8 @@ def Connection(connection: Optional['Redis'] = None): # noqa
connection (Optional[Redis], optional): A Redis Connection instance. Defaults to None.
"""
warnings.warn(
- "The Conneciton context manager is deprecated. Use the `connection` parameter instead.", DeprecationWarning
+ "The Conneciton context manager is deprecated. Use the `connection` parameter instead.",
+ DeprecationWarning,
)
if connection is None:
connection = Redis()
@@ -41,7 +43,8 @@ def Connection(connection: Optional['Redis'] = None): # noqa
finally:
popped = pop_connection()
assert popped == connection, (
- 'Unexpected Redis connection was popped off the stack. ' 'Check your Redis connection setup.'
+ 'Unexpected Redis connection was popped off the stack. '
+ 'Check your Redis connection setup.'
)
@@ -52,6 +55,10 @@ def push_connection(redis: 'Redis'):
Args:
redis (Redis): A Redis connection
"""
+ warnings.warn(
+ "The `push_connection` function is deprecated. Pass the `connection` explicitly instead.",
+ DeprecationWarning,
+ )
_connection_stack.push(redis)
@@ -62,6 +69,10 @@ def pop_connection() -> 'Redis':
Returns:
redis (Redis): A Redis connection
"""
+ warnings.warn(
+ "The `pop_connection` function is deprecated. Pass the `connection` explicitly instead.",
+ DeprecationWarning,
+ )
return _connection_stack.pop()
@@ -73,6 +84,10 @@ def get_current_connection() -> 'Redis':
Returns:
Redis: A Redis Connection
"""
+ warnings.warn(
+ "The `get_current_connection` function is deprecated. Pass the `connection` explicitly instead.",
+ DeprecationWarning,
+ )
return _connection_stack.top
@@ -90,7 +105,10 @@ def resolve_connection(connection: Optional['Redis'] = None) -> 'Redis':
Returns:
Redis: A Redis Connection
"""
-
+ warnings.warn(
+ "The `resolve_connection` function is deprecated. Pass the `connection` explicitly instead.",
+ DeprecationWarning,
+ )
if connection is not None:
return connection
@@ -102,4 +120,6 @@ def resolve_connection(connection: Optional['Redis'] = None) -> 'Redis':
_connection_stack = LocalStack()
+
__all__ = ['Connection', 'get_current_connection', 'push_connection', 'pop_connection']
+