[Python-modules-commits] [rpyc] 04/06: cherry pick: use poll() instead of select()

Carl Suster arcresu-guest at moszumanska.debian.org
Thu Jan 12 06:00:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

arcresu-guest pushed a commit to branch master
in repository rpyc.

commit f6a26e46066e8c98bddddab50a6711cf1d9ed130
Author: Carl Suster <carl at contraflo.ws>
Date:   Mon Jan 9 18:54:58 2017 +1100

    cherry pick: use poll() instead of select()
    
    Upstream commit:
    
      28ef9b694363c455afd4f513afabce778d9cc838
      Giuseppe Lo Presti committed on 11 Dec 2015
      Fixed bug #182: Stream uses select() and it is prone to its
      limitations
    
    This was causing errors about negative file descriptors sometimes.
    
    Origin: upstream, https://github.com/tomerfiliba/rpyc/commit/28ef9b694363c455afd4f513afabce778d9cc838
---
 rpyc/core/stream.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/rpyc/core/stream.py b/rpyc/core/stream.py
index 699d0d6..3aa7dbf 100644
--- a/rpyc/core/stream.py
+++ b/rpyc/core/stream.py
@@ -8,7 +8,7 @@ import socket
 import time
 import errno
 from rpyc.lib import safe_import
-from rpyc.lib.compat import select, select_error, BYTES_LITERAL, get_exc_errno, maxint
+from rpyc.lib.compat import poll, select_error, BYTES_LITERAL, get_exc_errno, maxint
 win32file = safe_import("win32file")
 win32pipe = safe_import("win32pipe")
 msvcrt = safe_import("msvcrt")
@@ -36,9 +36,11 @@ class Stream(object):
         """indicates whether the stream has data to read (within *timeout* 
         seconds)"""
         try:
+            p = poll()   # from lib.compat, it may be a select object on non-Unix platforms
+            p.register(self.fileno(), "r")
             while True:
                 try:
-                    rl, _, _ = select([self], [], [], timeout)
+                    rl = p.poll(timeout)
                 except select_error as ex:
                     if ex[0] == errno.EINTR:
                         continue
@@ -47,8 +49,10 @@ class Stream(object):
                 else:
                     break
         except ValueError as ex:
-            # i get this some times: "ValueError: file descriptor cannot be a negative integer (-1)"
-            # let's translate it to select.error
+            # if the underlying call is a select(), then the following errors may happen:
+            # - "ValueError: filedescriptor cannot be a negative integer (-1)"
+            # - "ValueError: filedescriptor out of range in select()"
+            # let's translate them to select.error
             raise select_error(str(ex))
         return bool(rl)
     def read(self, count):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/rpyc.git



More information about the Python-modules-commits mailing list