Skip to content

Allow capture_all to be passed to stream() #2302

Closed as not planned
Closed as not planned
@craigwalton-dsit

Description

@craigwalton-dsit

What is the feature and why do you need it:
I'd like to be able to set capture_all=False when making a stream(client.connect_get_namespaced_pod_exec, ...) call. capture_all is a parameter which your WSClient initialiser accepts (source).

I sometimes stream large amounts of data over stdout, something like this:

ws_client = stream(
    client.connect_get_namespaced_pod_exec,
    name="my-pod",
    namespace="my-namespace",
    command=["cat", "my-file.txt"],
    stdin=False,
    stdout=True,
    stderr=True,
    binary=True,
    _preload_content=False,
    _request_timeout=60,
)
while ws_client.is_open():
    ws_client.update(timeout=1)
    if ws_client.peek_stdout():
        frame = ws_client.read_stdout()
        # write frame to file-like object

I want to avoid storing all the stdout in memory at any given point. At present, unless I do ws_client.read_all() inside my loop, all the stdout+stderr builds up in WSClient._all.

Describe the solution you'd like to see:
The easiest approach looks to be: adapt the _websocket_request() function (source) to pop() capture_all from kwargs like is already done with binary.

Apologies if I'm missing a trick here and thanks for the invaluable library!

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions