Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Commit

Permalink
Use server-side timeouts for watching, disable socket timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Vasilyev committed Jul 12, 2019
1 parent 1aa3ea9 commit a72dbad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions kopf/clients/fetching.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ def watch_objs(*, resource, namespace=None, timeout=None, since=None):
* The resource is namespace-scoped AND operator is namespaced-restricted.
"""
api = auth.get_pykube_api(timeout=timeout)

params = {}
if timeout is not None:
params['timeoutSeconds'] = timeout

api = auth.get_pykube_api(timeout=None)
cls = classes._make_cls(resource=resource)
namespace = namespace if issubclass(cls, pykube.objects.NamespacedAPIObject) else None
lst = cls.objects(api, namespace=pykube.all if namespace is None else namespace)
src = lst.watch(since=since)
src = lst.watch(since=since, params=params)
return iter({'type': event.type, 'object': event.object.obj} for event in src)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
'click',
'iso8601',
'aiojobs',
'pykube-ng>=0.25',
'pykube-ng>=0.27',
],
)

0 comments on commit a72dbad

Please sign in to comment.