Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: time bug in ws_cilent #2265

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions kubernetes/base/stream/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ def read_channel(self, channel, timeout=0):
del self._channels[channel]
return ret

def readline_channel(self, channel, timeout=None):
def readline_channel(self, channel, timeout=1):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout can also default to 0 (it won't crash but it won't do anything)

"""Read a line from a channel."""
if timeout is None:
timeout = float("inf")
start = time.time()
while self.is_open() and time.time() - start < timeout:
if channel in self._channels:
Expand Down Expand Up @@ -165,7 +163,7 @@ def write_stdin(self, data):
"""The same as write_channel with channel=0."""
self.write_channel(STDIN_CHANNEL, data)

def update(self, timeout=0):
def update(self, timeout: float = 0):
"""Update channel buffers with at most one complete frame of input."""
if not self.is_open():
return
Expand Down