From 91d9587e45608a5f95cd842426b43452a60abb5e Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 3 Feb 2020 22:11:19 +0000 Subject: [PATCH] Revert "Port _FileDescriptorStreamsNonBlocking to use poll()" This reverts commit 1e01a7444536b4865feb94c398b68a936a463ddc. Not all platforms support select.poll() currently it seems. At least macOS's Python 2 doesn't (while macOS Python 3 does). Lets back this out for the existing release series and once we start repo-2 which is Python 3-only, we can put this back in. Change-Id: I205206b0fa4fe2d755f4fbc6ec683ad125f27cc2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253072 Reviewed-by: Michael Mortensen Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- platform_utils.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/platform_utils.py b/platform_utils.py index 20c00334..06ef9b18 100644 --- a/platform_utils.py +++ b/platform_utils.py @@ -90,11 +90,6 @@ class _FileDescriptorStreamsNonBlocking(FileDescriptorStreams): """ Implementation of FileDescriptorStreams for platforms that support non blocking I/O. """ - def __init__(self): - super(_FileDescriptorStreamsNonBlocking, self).__init__() - self._poll = select.poll() - self._fd_to_stream = {} - class Stream(object): """ Encapsulates a file descriptor """ def __init__(self, fd, dest, std_name): @@ -118,18 +113,11 @@ class _FileDescriptorStreamsNonBlocking(FileDescriptorStreams): self.fd.close() def _create_stream(self, fd, dest, std_name): - stream = self.Stream(fd, dest, std_name) - self._fd_to_stream[stream.fileno()] = stream - self._poll.register(stream, select.POLLIN) - return stream - - def remove(self, stream): - self._poll.unregister(stream) - del self._fd_to_stream[stream.fileno()] - super(_FileDescriptorStreamsNonBlocking, self).remove(stream) + return self.Stream(fd, dest, std_name) def select(self): - return [self._fd_to_stream[fd] for fd, _ in self._poll.poll()] + ready_streams, _, _ = select.select(self.streams, [], []) + return ready_streams class _FileDescriptorStreamsThreads(FileDescriptorStreams):