From bb50fb86648da92f6fde502a7c6aefc4514514c0 Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Fri, 29 May 2020 03:40:07 +0000 Subject: [PATCH] use higher level API `selectors` instead of `select` (#3899) --- dvc/remote/ssh/connection.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dvc/remote/ssh/connection.py b/dvc/remote/ssh/connection.py index c68334c2c..3c2a16e35 100644 --- a/dvc/remote/ssh/connection.py +++ b/dvc/remote/ssh/connection.py @@ -237,11 +237,15 @@ class SSHConnection: or channel.recv_ready() or channel.recv_stderr_ready() ): - import select + import selectors + + selector = selectors.DefaultSelector() + selector.register(stdout.channel, selectors.EVENT_READ) got_chunk = False - readq, _, _ = select.select([stdout.channel], [], [], self.timeout) - for c in readq: + events = selector.select(self.timeout) + for key, _ in events: + c = key.fileobj if c.recv_ready(): stdout_chunks.append(stdout.channel.recv(len(c.in_buffer))) got_chunk = True