Skip to content

Commit 037b662

Browse files
author
Nicolas Steinmetz
committed
feat: upgrade to redis-py6 as it supports all python and redis versions
1 parent 5851ffe commit 037b662

File tree

6 files changed

+3
-86
lines changed

6 files changed

+3
-86
lines changed

arq/connections.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class RedisSettings:
4949
sentinel: bool = False
5050
sentinel_master: str = 'mymaster'
5151

52-
retry_on_timeout: bool = False
5352
retry_on_error: Optional[list[Exception]] = None
5453
retry: Optional[Retry] = None
5554

@@ -263,7 +262,6 @@ def pool_factory(*args: Any, **kwargs: Any) -> ArqRedis:
263262
ssl_ca_data=settings.ssl_ca_data,
264263
ssl_check_hostname=settings.ssl_check_hostname,
265264
retry=settings.retry,
266-
retry_on_timeout=settings.retry_on_timeout,
267265
retry_on_error=settings.retry_on_error,
268266
max_connections=settings.max_connections,
269267
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ classifiers = [
3838
]
3939
requires-python = '>=3.9'
4040
dependencies = [
41-
'redis[hiredis]>=5.3.0,<6',
41+
'redis[hiredis]>=6.0,<7',
4242
'click>=8.0,<8.2',
4343
]
4444
optional-dependencies = {watch = ['watchfiles>=1.0'] }

requirements/pyproject.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ hiredis==3.1.1
1212
# via redis
1313
idna==3.10
1414
# via anyio
15-
pyjwt==2.9.0
16-
# via redis
17-
redis==5.3.0
15+
redis==6.1.0
1816
# via arq (pyproject.toml)
1917
sniffio==1.3.1
2018
# via anyio

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ async def arq_redis_retry(test_redis_host: str, test_redis_port: int):
8282
port=test_redis_port,
8383
encoding='utf-8',
8484
retry=Retry(backoff=NoBackoff(), retries=3),
85-
retry_on_timeout=True,
8685
retry_on_error=[redis.exceptions.ConnectionError],
8786
)
8887
await redis_.flushall()

tests/test_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_settings_changed():
2323
"ssl=False, ssl_keyfile=None, ssl_certfile=None, ssl_cert_reqs='required', ssl_ca_certs=None, "
2424
'ssl_ca_data=None, ssl_check_hostname=False, conn_timeout=1, conn_retries=5, conn_retry_delay=1, '
2525
"max_connections=None, sentinel=False, sentinel_master='mymaster', "
26-
'retry_on_timeout=False, retry_on_error=None, retry=None)'
26+
'retry_on_error=None, retry=None)'
2727
) == str(settings)
2828

2929

@@ -221,7 +221,6 @@ def test_settings_plain():
221221
'conn_retry_delay': 1,
222222
'sentinel': False,
223223
'sentinel_master': 'mymaster',
224-
'retry_on_timeout': False,
225224
'retry_on_error': None,
226225
'retry': None,
227226
'max_connections': None,
@@ -250,7 +249,6 @@ def test_settings_from_socket_dsn():
250249
'conn_retry_delay': 1,
251250
'sentinel': False,
252251
'sentinel_master': 'mymaster',
253-
'retry_on_timeout': False,
254252
'retry_on_error': None,
255253
'retry': None,
256254
'max_connections': None,

tests/test_worker.py

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,79 +1058,3 @@ async def test_worker_timezone_defaults_to_system_timezone(worker):
10581058
worker = worker(functions=[func(foobar)])
10591059
assert worker.timezone is not None
10601060
assert worker.timezone == datetime.now().astimezone().tzinfo
1061-
1062-
1063-
@pytest.mark.parametrize(
1064-
'exception_thrown',
1065-
[
1066-
redis.exceptions.ConnectionError('Error while reading from host'),
1067-
redis.exceptions.TimeoutError('Timeout reading from host'),
1068-
],
1069-
)
1070-
async def test_worker_retry(mocker, worker_retry, exception_thrown):
1071-
# Testing redis exceptions, with retry settings specified
1072-
worker = worker_retry(functions=[func(foobar)])
1073-
1074-
# patch db read_response to mimic connection exceptions
1075-
p = patch.object(worker.pool.connection_pool.connection_class, 'read_response', side_effect=exception_thrown)
1076-
1077-
# baseline
1078-
await worker.main()
1079-
await worker._poll_iteration()
1080-
1081-
# spy method handling call_with_retry failure
1082-
spy = mocker.spy(worker.pool, '_disconnect_raise')
1083-
1084-
try:
1085-
# start patch
1086-
p.start()
1087-
1088-
# assert exception thrown
1089-
with pytest.raises(type(exception_thrown)):
1090-
await worker._poll_iteration()
1091-
1092-
# assert retry counts and no exception thrown during '_disconnect_raise'
1093-
assert spy.call_count == 4 # retries setting + 1
1094-
assert spy.spy_exception is None
1095-
1096-
finally:
1097-
# stop patch to allow worker cleanup
1098-
p.stop()
1099-
1100-
1101-
@pytest.mark.parametrize(
1102-
'exception_thrown',
1103-
[
1104-
redis.exceptions.ConnectionError('Error while reading from host'),
1105-
redis.exceptions.TimeoutError('Timeout reading from host'),
1106-
],
1107-
)
1108-
async def test_worker_crash(mocker, worker, exception_thrown):
1109-
# Testing redis exceptions, no retry settings specified
1110-
worker = worker(functions=[func(foobar)])
1111-
1112-
# patch db read_response to mimic connection exceptions
1113-
p = patch.object(worker.pool.connection_pool.connection_class, 'read_response', side_effect=exception_thrown)
1114-
1115-
# baseline
1116-
await worker.main()
1117-
await worker._poll_iteration()
1118-
1119-
# spy method handling call_with_retry failure
1120-
spy = mocker.spy(worker.pool, '_disconnect_raise')
1121-
1122-
try:
1123-
# start patch
1124-
p.start()
1125-
1126-
# assert exception thrown
1127-
with pytest.raises(type(exception_thrown)):
1128-
await worker._poll_iteration()
1129-
1130-
# assert no retry counts and exception thrown during '_disconnect_raise'
1131-
assert spy.call_count == 1
1132-
assert spy.spy_exception == exception_thrown
1133-
1134-
finally:
1135-
# stop patch to allow worker cleanup
1136-
p.stop()

0 commit comments

Comments
 (0)