Skip to content

Commit f72f921

Browse files
archy-rock3t-cloudyliaog
authored andcommitted
Fix readline_channel crash and None return on default timeout
Signed-off-by: Artem Muterko <[email protected]>
1 parent bb887bb commit f72f921

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎kubernetes/base/stream/ws_client.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def readline_channel(self, channel, timeout=None):
128128
return b"" if self.binary else ""
129129

130130
self.update(timeout=(timeout - time.time() + start))
131+
return b"" if self.binary else ""
131132

132133
def write_channel(self, channel, data):
133134
"""Write data to a channel."""
@@ -216,11 +217,15 @@ def update(self, timeout=0):
216217
if hasattr(select, "poll"):
217218
poll = select.poll()
218219
poll.register(self.sock.sock, select.POLLIN)
219-
if timeout is not None:
220+
if timeout is not None and timeout != float("inf"):
220221
timeout *= 1_000 # poll method uses milliseconds as the time unit
222+
else:
223+
timeout = None
221224
r = poll.poll(timeout)
222225
poll.unregister(self.sock.sock)
223226
else:
227+
if timeout == float("inf"):
228+
timeout = None
224229
r, _, _ = select.select(
225230
(self.sock.sock, ), (), (), timeout)
226231

0 commit comments

Comments
 (0)