Skip to content

Support _request_timeout in dynamic client watch() #2533

Closed

Description

@amel-ch

Problem

When using the dynamic client’s watch() method:

api = self._client.resources.get(
    api_version=self._api_version,
    kind=self._kind
)

for event in api.watch(
    timeout=server_timeout_seconds,
)

there is currently no way to configure a client-side request timeout (_request_timeout).

Current Workaround

To enforce a client-side timeout, we have to bypass Resource.watch() and directly use Watch().stream():

for raw_event in Watch().stream(
    api.get,
    serialize=False,
    deserialize=False,
    timeout_seconds=self._server_timeout_seconds,
    _request_timeout=self._client_timeout_seconds,
)

Issue

The dynamic client’s watch() method internally relies on Watch().stream() but does not expose _request_timeout as a parameter: https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/client.py#L203

This creates:
Inconsistent API ergonomics
Unnecessary duplication of logic for users needing client-side timeouts

Proposed Solution

Extend Resource.watch() to accept an optional _request_timeout parameter and pass it through to the underlying Watch().stream() call.

Example:

api.watch(
    timeout=server_timeout_seconds,
    _request_timeout=(connect_timeout, read_timeout),
)

Activity

  1. added
    kind/feature
    on Apr 1, 2026
  2. changed the title [-]Support _request_timeout in dynamic client watch() API[/-] [+]Support _request_timeout in dynamic client watch()[/+] on Apr 1, 2026
  3. Polimixanos commented on Apr 21, 2026

    @Polimixanos

    Can I work on this?

  4. roycaihw commented on Apr 23, 2026

    @roycaihw
    Member

    /assign @Polimixanos

  5. roycaihw commented on Apr 23, 2026

    @roycaihw
    Member
  6. santiagorojas14 commented on Aug 19, 2026

    @santiagorojas14

    Should the _request_timeout parameter in Resource.watch() be designed to accept a tuple for separate connect and read timeouts, or should it be a single integer that applies to both?

  7. absolutegar commented on Sep 28, 2026

    @absolutegar

    We should probably define _request_timeout=None explicitly in Resource.watch()'s signature and pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions