Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow max_connections to be set in RedisSettings #406

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions arq/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class RedisSettings:
conn_timeout: int = 1
conn_retries: int = 5
conn_retry_delay: int = 1
max_connections: Optional[int] = None

sentinel: bool = False
sentinel_master: str = 'mymaster'
Expand Down Expand Up @@ -264,6 +265,7 @@ def pool_factory(*args: Any, **kwargs: Any) -> ArqRedis:
retry=settings.retry,
retry_on_timeout=settings.retry_on_timeout,
retry_on_error=settings.retry_on_error,
max_connections=settings.max_connections,
)

while True:
Expand Down
5 changes: 4 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def test_settings_changed():
"RedisSettings(host='localhost', port=123, unix_socket_path=None, database=0, username=None, password=None, "
"ssl=False, ssl_keyfile=None, ssl_certfile=None, ssl_cert_reqs='required', ssl_ca_certs=None, "
'ssl_ca_data=None, ssl_check_hostname=False, conn_timeout=1, conn_retries=5, conn_retry_delay=1, '
"sentinel=False, sentinel_master='mymaster', retry_on_timeout=False, retry_on_error=None, retry=None)"
"max_connections=None, sentinel=False, sentinel_master='mymaster', "
'retry_on_timeout=False, retry_on_error=None, retry=None)'
) == str(settings)


Expand Down Expand Up @@ -224,6 +225,7 @@ def test_settings_plain():
'retry_on_timeout': False,
'retry_on_error': None,
'retry': None,
'max_connections': None,
}


Expand Down Expand Up @@ -252,4 +254,5 @@ def test_settings_from_socket_dsn():
'retry_on_timeout': False,
'retry_on_error': None,
'retry': None,
'max_connections': None,
}