Skip to content

Commit

Permalink
Allow max_connections to be set in RedisSettings (#406)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuel Colvin <[email protected]>
  • Loading branch information
danbox and samuelcolvin authored Apr 1, 2024
1 parent 3de6d87 commit 9731f54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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,
}

0 comments on commit 9731f54

Please sign in to comment.