Skip to content
Open
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
8 changes: 7 additions & 1 deletion kubernetes/base/dynamic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def server_side_apply(self, resource, body=None, name=None, namespace=None, forc

return self.request('patch', path, body=body, force_conflicts=force_conflicts, **kwargs)

def watch(self, resource, namespace=None, name=None, label_selector=None, field_selector=None, resource_version=None, timeout=None, watcher=None, allow_watch_bookmarks=None):
def watch(self, resource, namespace=None, name=None, label_selector=None, field_selector=None, resource_version=None, timeout=None, watcher=None, allow_watch_bookmarks=None, _request_timeout=None):
"""
Stream events for a resource from the Kubernetes API

Expand All @@ -177,6 +177,7 @@ def watch(self, resource, namespace=None, name=None, label_selector=None, field_
:param timeout: The amount of time in seconds to wait before terminating the stream
:param watcher: The Watcher object that will be used to stream the resource
:param allow_watch_bookmarks: Ask the API server to send BOOKMARK events
:param _request_timeout: The amount of time in seconds to wait for a request to complete

:return: Event object with these keys:
'type': The type of event such as "ADDED", "DELETED", etc.
Expand All @@ -193,6 +194,10 @@ def watch(self, resource, namespace=None, name=None, label_selector=None, field_
print(e['object'].metadata)
# If you want to gracefully stop the stream watcher
watcher.stop()

# Using a client-side request timeout
for e in v1_pods.watch(timeout=60, _request_timeout=(5, 65)):
print(e['type'])
"""
if not watcher: watcher = watch.Watch()

Expand All @@ -209,6 +214,7 @@ def watch(self, resource, namespace=None, name=None, label_selector=None, field_
serialize=False,
timeout_seconds=timeout,
allow_watch_bookmarks=allow_watch_bookmarks,
_request_timeout=_request_timeout,
):
event['object'] = ResourceInstance(resource, event['object'])
yield event
Expand Down