Skip to content

How to perform non-blocking reads using read_namespaced_pod_log #2474

@emike922

Description

@emike922

I am trying to set up a background thread that follows the log stream of a container and performs some actions on each record. The thread shall have a means to gracefully terminate it from the main thread, e.g. using threading.Event.

I have tried various combinations of read_namespaced_pod_log with follow=True. Iterating over read_namespaced_pod_log(...).stream(), iterating over Watch().stream(), passing _preload_content=False and such. But it always comes down to this: The for loop / next() / iter_resp_lines() call eventually blocks once we are all caught up with the container's logs, and setting the Event during this time will not terminate the thread until the next log event occurs.

Could you please provide an example on how to do non-blocking reads with read_namespaced_pod_log?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions