Skip to content

Commit 96bb982

Browse files
therveci.datadog-api-spec
andauthored
Fix handling of timeout in async client (#1505)
* Fix handling of timeout in async client aiosonic expects objects not raw numbers in timeout. Fixes #1502 * pre-commit fixes * Skip typing --------- Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent a5824d4 commit 96bb982

File tree

2 files changed

+14
-0
lines changed
  • .generator/src/generator/templates
  • src/datadog_api_client

2 files changed

+14
-0
lines changed

.generator/src/generator/templates/rest.j2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ class AsyncRESTClientObject:
266266
(connection, read) timeouts.
267267
"""
268268
assert not post_params, "not supported for now"
269+
if request_timeout is not None:
270+
from aiosonic.timeout import Timeouts # type: ignore
271+
272+
if isinstance(request_timeout, (int, float)):
273+
request_timeout = Timeouts(request_timeout=request_timeout)
274+
else:
275+
request_timeout = Timeouts(sock_connect=request_timeout[0], sock_read=request_timeout[1])
269276
request_body = None
270277
if (
271278
"Content-Type" not in headers

src/datadog_api_client/rest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ async def request(
268268
(connection, read) timeouts.
269269
"""
270270
assert not post_params, "not supported for now"
271+
if request_timeout is not None:
272+
from aiosonic.timeout import Timeouts # type: ignore
273+
274+
if isinstance(request_timeout, (int, float)):
275+
request_timeout = Timeouts(request_timeout=request_timeout)
276+
else:
277+
request_timeout = Timeouts(sock_connect=request_timeout[0], sock_read=request_timeout[1])
271278
request_body = None
272279
if (
273280
"Content-Type" not in headers

0 commit comments

Comments
 (0)