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

Commit

Permalink
Allow for custom timeout in watch request
Browse files Browse the repository at this point in the history
this will allow to set a custom aiohttp.ClientTimeout object
when making the ?watch=true request to Kubernetes API if needed.

related issue 204
  • Loading branch information
pshchelo committed Mar 6, 2020
1 parent 51a3a70 commit 4c2cfdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kopf/clients/watching.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async def watch_objs(
# Talk to the API and initiate a streaming response.
response = await context.session.get(
url=resource.get_url(server=context.server, namespace=namespace, params=params),
timeout=aiohttp.ClientTimeout(total=None),
timeout=config.WatchersConfig.session_timeout,
)
response.raise_for_status()

Expand Down
5 changes: 5 additions & 0 deletions kopf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import logging
from typing import Optional

import aiohttp

from kopf.engines import logging as logging_engine

format = '[%(asctime)s] %(name)-20.20s [%(levelname)-8.8s] %(message)s'
Expand Down Expand Up @@ -121,3 +123,6 @@ class WatchersConfig:

watcher_retry_delay: float = 0.1
""" How long should a pause be between watch requests (to prevent flooding). """

session_timeout: aiohttp.ClientTimeout = aiohttp.ClientTimeout(total=None)
""" aiohttp ClientTimeout object to use in watch request. """

0 comments on commit 4c2cfdf

Please sign in to comment.