Commits

Ronny Pfannschmidt committed cf476cc

various patch changes

Comments (0)

Files changed (3)

gateway-io-proxying.patch

 # HG changeset patch
-# Parent da4181682b854327ab1c96d1b8a03b7c86a68caf
+# Parent 3c5364e6635a25f4e5e8293a3dcca85f7bf0c748
 
-diff --git a/execnet/bootstraper.py b/execnet/bootstraper.py
+diff --git a/execnet/gateway.py b/execnet/gateway.py
+--- a/execnet/gateway.py
++++ b/execnet/gateway.py
+@@ -10,6 +10,9 @@ from execnet.gateway_base import Message
+ from execnet import gateway_base
+ importdir = os.path.dirname(os.path.dirname(execnet.__file__))
+ 
++from execnet.start_remotes import sendexec, popen_bootstrapline
++
++
+ class Gateway(gateway_base.BaseGateway):
+     """ Gateway to a local or remote Python Intepreter. """
+ 
+@@ -229,7 +232,6 @@ class PopenCmdGateway(Gateway):
+             p.pid = self.remote_exec(
+                 "import os; channel.send(os.getpid())").receive()
+ 
+-popen_bootstrapline = "import sys;exec(eval(sys.stdin.readline()))"
+ class PopenGateway(PopenCmdGateway):
+     """ This Gateway provides interaction with a newly started
+         python subprocess.
+@@ -262,9 +264,6 @@ class PopenGateway(PopenCmdGateway):
+         s = io.read(1)
+         assert s == "1".encode('ascii')
+ 
+-def sendexec(io, *sources):
+-    source = "\n".join(sources)
+-    io.write((repr(source)+ "\n").encode('ascii'))
+ 
+ class HostNotFound(Exception):
+     pass
+diff --git a/execnet/start_remotes.py b/execnet/start_remotes.py
 new file mode 100644
 --- /dev/null
-+++ b/execnet/bootstraper.py
++++ b/execnet/start_remotes.py
 @@ -0,0 +1,20 @@
 +"""
-+tools to send over bootstrap code to a given io
++utility functions to start different types of io's including their remote setup
 +"""
 +from execnet import gateway_base
 +
 +    )
 +    s = io.read(1)
 +    assert s == "1".encode('ascii')
-diff --git a/execnet/gateway.py b/execnet/gateway.py
---- a/execnet/gateway.py
-+++ b/execnet/gateway.py
-@@ -62,6 +62,7 @@ class Gateway(gateway_base.BaseGateway):
-         """ send gateway bootstrap code to a remote Python interpreter
-             endpoint, which reads from io for a string to execute.
-         """
-+        b
-         sendexec(io,
-             inspect.getsource(gateway_base),
-             self._remotesetup,
-@@ -229,7 +230,6 @@ class PopenCmdGateway(Gateway):
-             p.pid = self.remote_exec(
-                 "import os; channel.send(os.getpid())").receive()
- 
--popen_bootstrapline = "import sys;exec(eval(sys.stdin.readline()))"
- class PopenGateway(PopenCmdGateway):
-     """ This Gateway provides interaction with a newly started
-         python subprocess.
-@@ -262,9 +262,6 @@ class PopenGateway(PopenCmdGateway):
-         s = io.read(1)
-         assert s == "1".encode('ascii')
- 
--def sendexec(io, *sources):
--    source = "\n".join(sources)
--    io.write((repr(source)+ "\n").encode('ascii'))
- 
- class HostNotFound(Exception):
-     pass
-diff --git a/execnet/initialize_io.py b/execnet/initialize_io.py
-new file mode 100644
---- /dev/null
-+++ b/execnet/initialize_io.py
-@@ -0,0 +1,3 @@
-+"""
-+tools to create io's on local or remotes
-+"""

io-creation-split

+# HG changeset patch
+# Parent 7bdfdda4dfb68a8f9b3be89ab390e847078d626e
+diff --git a/execnet/gateway.py b/execnet/gateway.py
+--- a/execnet/gateway.py
++++ b/execnet/gateway.py
+@@ -221,8 +221,8 @@ class PopenCmdGateway(Gateway):
+     _remotesetup = "io = init_popen_io()"
+     def __init__(self, args, id):
+         from subprocess import Popen, PIPE
+-        self._popen = p = Popen(args, stdin=PIPE, stdout=PIPE)
+-        io = Popen2IO(p.stdin, p.stdout)
++        p = Popen(args, stdin=PIPE, stdout=PIPE)
++        io = Popen2IO(p.stdin, p.stdout, p)
+         super(PopenCmdGateway, self).__init__(io=io, id=id)
+         # fix for jython 2.5.1
+         if p.pid is None:
+@@ -293,6 +293,6 @@ class SshGateway(PopenCmdGateway):
+         try:
+             super(SshGateway, self)._remote_bootstrap_gateway(io)
+         except EOFError:
+-            ret = self._popen.wait()
++            ret = self.io.wait()
+             if ret == 255:
+                 raise HostNotFound(self.remoteaddress)
+diff --git a/execnet/gateway_base.py b/execnet/gateway_base.py
+--- a/execnet/gateway_base.py
++++ b/execnet/gateway_base.py
+@@ -70,9 +70,10 @@ else:
+ class Popen2IO:
+     error = (IOError, OSError, EOFError)
+ 
+-    def __init__(self, outfile, infile):
++    def __init__(self, outfile, infile, popen=None):
+         # we need raw byte streams
+         self.outfile, self.infile = outfile, infile
++        self.popen = popen
+         if sys.platform == "win32":
+             import msvcrt
+             try:
+@@ -106,6 +107,9 @@ class Popen2IO:
+     def close_write(self):
+         self.outfile.close()
+ 
++    def wait(self):
++        return self.popen.wait()
++
+ class Message:
+     """ encapsulates Messages and their wire protocol. """
+     _types = []
+diff --git a/execnet/gateway_socket.py b/execnet/gateway_socket.py
+--- a/execnet/gateway_socket.py
++++ b/execnet/gateway_socket.py
+@@ -15,6 +15,9 @@ class SocketIO:
+         except (AttributeError, socket.error):
+             sys.stderr.write("WARNING: cannot set socketoption")
+ 
++    def wait(self):
++        pass
++
+     def read(self, numbytes):
+         "Read exactly 'bytes' bytes from the socket."
+         buf = bytes()
+diff --git a/execnet/multi.py b/execnet/multi.py
+--- a/execnet/multi.py
++++ b/execnet/multi.py
+@@ -151,8 +151,7 @@ class Group:
+                 gw.join()
+             while self._gateways_to_join:
+                 gw = self._gateways_to_join[0]
+-                if hasattr(gw, '_popen'):
+-                    gw._popen.wait()
++                gw._io.wait()
+                 del self._gateways_to_join[0]
+         from execnet.threadpool import WorkerPool
+         pool = WorkerPool(1)
+@@ -164,7 +163,7 @@ class Group:
+                   %(self._gateways_to_join))
+             while self._gateways_to_join:
+                 gw = self._gateways_to_join.pop(0)
+-                popen = getattr(gw, '_popen', None)
++                popen = getattr(gw._io, 'popen', None)
+                 if popen:
+                     killpopen(popen)
+ 
+io-creation-split
 strconfig-decouple-effects
 socketserver-rexec
 gateway-io-proxying.patch