[py-svn] r7912 - py/dist/py/execnet

hpk at codespeak.net hpk at codespeak.net
Fri Dec 17 20:49:43 CET 2004


Author: hpk
Date: Fri Dec 17 20:49:43 2004
New Revision: 7912

Modified:
   py/dist/py/execnet/register.py
Log:
make PopenGateways a bit more seemless with
respect to importing packages across process 
spaces (basically the other side inherits 
sys.path from the originating process ) 



Modified: py/dist/py/execnet/register.py
==============================================================================
--- py/dist/py/execnet/register.py	(original)
+++ py/dist/py/execnet/register.py	Fri Dec 17 20:49:43 2004
@@ -12,7 +12,7 @@
         self.remote_bootstrap_gateway(io) 
         gateway.Gateway.__init__(self, io=io, startcount=1)
 
-    def remote_bootstrap_gateway(self, io): 
+    def remote_bootstrap_gateway(self, io, extra=''): 
         """ return Gateway with a asynchronously remotely 
             initialized counterpart Gateway (which may or may not succeed). 
             Note that the other sides gateways starts enumerating 
@@ -21,6 +21,7 @@
             uniquely identify channels across both sides. 
         """
         bootstrap = [ 
+            extra, 
             inspect.getsource(inputoutput), 
             inspect.getsource(message), 
             inspect.getsource(channel), 
@@ -38,7 +39,20 @@
         infile, outfile = os.popen2(cmd)
         io = inputoutput.Popen2IO(infile, outfile) 
         InstallableGateway.__init__(self, io=io) 
-        self._pidchannel = self.remote_exec("import os ; channel.send(os.getpid())")
+
+        self._pidchannel = self.remote_exec(""" 
+            import os 
+            channel.send(os.getpid()) 
+        """) 
+
+    def remote_bootstrap_gateway(self, io, extra=''): 
+        # XXX the following hack helps us to import the same version 
+        #     of the py lib, but only works for PopenGateways 
+        #     --> we need proper remote imports working 
+        #         across any kind of gateway!
+        s = "import sys ; sys.path[:] = %r" % (sys.path,) 
+        s = "\n".join([extra, s]) 
+        super(PopenGateway, self).remote_bootstrap_gateway(io, s) 
 
     def exit(self):
         if not super(PopenGateway, self).exit():



More information about the pytest-commit mailing list