Skip to content

Commit b7ec53c

Browse files
fix unspecified dynamic client watch timeout (#320)
Currently, when a dynamic client watcher is used, timeout_seconds is always passed to watcher.stream() from DynamicClient.watch(). Its value is None when the timeout argument was not passed by the user. The current check done on TimeoutError in the Watch.watch() method when awaiting from self.resp.content.readline() prevents to reopen the request in this case because it behaves differently if timeout_seconds was set to None or if timeout_seconds was not passed to the function. Do not pass the timeout_seconds argument in DynamicClient.watch() if timeout was not specified by the user. Signed-off-by: Olivier Matz <[email protected]>
1 parent 03f4dd8 commit b7ec53c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kubernetes_asyncio/dynamic/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,18 @@ async def watch(resource, namespace=None, name=None, label_selector=None, field_
214214
if name:
215215
field_selector = f"metadata.name={name}"
216216

217+
kwargs = {}
218+
if timeout is not None:
219+
kwargs['timeout_seconds'] = timeout
220+
217221
async for event in watcher.stream(
218222
resource.get,
219223
namespace=namespace,
220224
field_selector=field_selector,
221225
label_selector=label_selector,
222226
resource_version=resource_version,
223227
serialize=False,
224-
timeout_seconds=timeout
228+
**kwargs
225229
):
226230
event['object'] = ResourceInstance(resource, event['object'])
227231
yield event

0 commit comments

Comments
 (0)