-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
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?