Commits

holger krekel committed aecdbed

improve channel.receive() communication latency on python2
by changing the default timeout of the underlying Queue.get
to a regular None instead of the previous default -1
which caused an internal positive timeout value
(a hack probably introduced to allow CTRL-C to pass
through for <python2.5 versions).

Comments (0)

Files changed (2)

 1.X
 --------------------------------
 
+- change license from GPL to MIT
+
 - introduce execnet.dump/load variants of dumps/loads
   serializing/unserializing mechanism.
 
+- improve channel.receive() communication latency on python2
+  by changing the default timeout of the underlying Queue.get
+  to a regular None instead of the previous default -1 
+  which caused an internal positive timeout value
+  (a hack probably introduced to allow CTRL-C to pass
+  through for <python2.5 versions).
+
 - extended ssh-syntax to allow passing of command line args, 
   e.g.  "ssh= -p 50 hostname". The options are passed to 
   the underlying ssh client binary.  Thanks tundish.
 - fix issue10 : skip PYTHONDONTWRITEBYTECODE test if 
   it we are running with PYTHONDONTWRITEBYTECODE set.
 
-- change license to MIT
-
 - dont try the jython pid fixup on a RemoteIO
 
 - avoid accidentally setting exc_info() in gateway_base.py

execnet/gateway_base.py

             raise IOError("cannot send to %r" %(self,))
         self.gateway._send(Message.CHANNEL_DATA, self.id, dumps_internal(item))
 
-    def receive(self, timeout=-1):
+    def receive(self, timeout=None):
         """receive a data item that was sent from the other side.
-        timeout: -1 [default] blocked waiting, but wake up periodically
-        to let CTRL-C through.  A positive number indicates the
-        number of seconds after which a channel.TimeoutError exception
-        will be raised if no item was received.
+        timeout: None [default] blocked waiting.  A positive number
+        indicates the number of seconds after which a channel.TimeoutError
+        exception will be raised if no item was received.
         Note that exceptions from the remotely executing code will be
         reraised as channel.RemoteError exceptions containing
         a textual representation of the remote traceback.
         itemqueue = self._items
         if itemqueue is None:
             raise IOError("cannot receive(), channel has receiver callback")
-        if timeout < 0:
-            internal_timeout = self._INTERNALWAKEUP
-        else:
-            internal_timeout = timeout
-
-        while 1:
-            try:
-                x = itemqueue.get(timeout=internal_timeout)
-                break
-            except queue.Empty:
-                if timeout < 0:
-                    continue
-                raise self.TimeoutError("no item after %r seconds" %(timeout))
+        try:
+            x = itemqueue.get(timeout=timeout)
+        except queue.Empty:
+            raise self.TimeoutError("no item after %r seconds" %(timeout))
         if x is ENDMARKER:
             itemqueue.put(x)  # for other receivers
             raise self._getremoteerror() or EOFError()