Skip to content

Commit 7b7ce99

Browse files
committed
Require command_timeout argument of connect() be greater than 0.
1 parent b1f87eb commit 7b7ce99

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

asyncpg/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ async def connect(dsn=None, *,
777777
778778
:param float command_timeout:
779779
the default timeout for operations on this connection
780-
(the default is no timeout).
780+
(the default is ``None``: no timeout).
781781
782782
:param ssl:
783783
pass ``True`` or an `ssl.SSLContext <SSLContext_>`_ instance to
@@ -825,12 +825,12 @@ async def connect(dsn=None, *,
825825
if isinstance(command_timeout, bool):
826826
raise ValueError
827827
command_timeout = float(command_timeout)
828-
if command_timeout < 0:
828+
if command_timeout <= 0:
829829
raise ValueError
830830
except ValueError:
831831
raise ValueError(
832832
'invalid command_timeout value: '
833-
'expected non-negative float (got {!r})'.format(
833+
'expected greater than 0 float (got {!r})'.format(
834834
command_timeout)) from None
835835

836836
addrs, opts = _parse_connect_params(

tests/test_connect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ def test_connect_params(self):
422422
self.run_testcase(testcase)
423423

424424
async def test_connect_args_validation(self):
425-
for val in {-1, 'a', True, False}:
426-
with self.assertRaisesRegex(ValueError, 'non-negative'):
425+
for val in {-1, 'a', True, False, 0}:
426+
with self.assertRaisesRegex(ValueError, 'greater than 0'):
427427
await asyncpg.connect(command_timeout=val)
428428

429429
for arg in {'max_cacheable_statement_size',

0 commit comments

Comments
 (0)