Example #1
0
 def setup(self, out=None):
     if out is None:
         out = py.io.TerminalWriter()
     if hasattr(self, "gateway"):
         raise ValueError("already have gateway %r" % self.gateway)
     self.trace("setting up slave session")
     old = self.config.topdir.chdir()
     try:
         self.gateway = self.initgateway()
     finally:
         old.chdir()
     channel = self.gateway.remote_exec(
         source="""
         from py.__.test.dist.mypickle import PickleChannel
         from py.__.test.looponfail.remote import slave_runsession
         channel = PickleChannel(channel)
         config, fullwidth, hasmarkup = channel.receive()
         slave_runsession(channel, config, fullwidth, hasmarkup) 
     """,
         stdout=out,
         stderr=out,
     )
     channel = PickleChannel(channel)
     channel.send((self.config, out.fullwidth, out.hasmarkup))
     self.trace("set up of slave session complete")
     self.channel = channel
Example #2
0
 def test_popen_with_newchannel(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         newchannel = channel.receive()
         newchannel.send(42)
     """)
     channel = PickleChannel(channel)
     newchannel = self.gw.newchannel()
     channel.send(newchannel)
     channel.waitclose()
     res = newchannel.receive()
     assert res == 42
Example #3
0
def test_config__setstate__wired_correctly_in_childprocess(testdir):
    from py.__.test.dist.mypickle import PickleChannel
    gw = py.execnet.PopenGateway()
    channel = gw.remote_exec("""
        import py
        from py.__.test.dist.mypickle import PickleChannel
        channel = PickleChannel(channel)
        config = channel.receive()
        assert py.test.config.pluginmanager.comregistry == py._com.comregistry, "comregistry wrong"
    """)
    channel = PickleChannel(channel)
    config = testdir.parseconfig()
    channel.send(config)
    channel.waitclose() # this will potentially raise 
    gw.exit()
Example #4
0
 def test_popen_with_callback(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         from py.__.test.dist.testing.test_mypickle import A
         a1 = A()
         a1.hello = 10
         channel.send(a1)
         a2 = channel.receive()
         channel.send(a2 is a1)
     """)
     channel = PickleChannel(channel)
     queue = py.std.Queue.Queue()
     channel.setcallback(queue.put)
     a_received = queue.get(timeout=TESTTIMEOUT)
     assert isinstance(a_received, A)
     assert a_received.hello == 10
     channel.send(a_received)
Example #5
0
 def test_popen_with_callback_with_endmarker_and_unpickling_error(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         from py.__.test.dist.testing.test_mypickle import A
         a1 = A()
         channel.send(a1)
         channel.send(a1)
     """)
     channel = PickleChannel(channel)
     queue = py.std.Queue.Queue()
     a = channel.receive()
     channel._ipickle._unpicklememo.clear()
     channel.setcallback(queue.put, endmarker=-1)
     next = queue.get(timeout=TESTTIMEOUT)
     assert next == -1 
     error = channel._getremoteerror()
     assert isinstance(error, UnpickleError)
Example #6
0
 def test_popen_send_instance(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         from py.__.test.dist.testing.test_mypickle import A
         a1 = A()
         a1.hello = 10
         channel.send(a1)
         a2 = channel.receive()
         channel.send(a2 is a1)
     """)
     channel = PickleChannel(channel)
     a_received = channel.receive()
     assert isinstance(a_received, A)
     assert a_received.hello == 10
     channel.send(a_received)
     remote_a2_is_a1 = channel.receive()
     assert remote_a2_is_a1 
Example #7
0
 def test_popen_with_various_methods(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         channel.receive()
     """)
     channel = PickleChannel(channel)
     assert not channel.isclosed()
     assert not channel._getremoteerror()
     channel.send(2)
     channel.waitclose(timeout=2)
Example #8
0
def install_slave(gateway, config):
    channel = gateway.remote_exec(source="""
        import os, sys 
        sys.path.insert(0, os.getcwd()) 
        from py.__.test.dist.mypickle import PickleChannel
        from py.__.test.dist.txnode import SlaveNode
        channel = PickleChannel(channel)
        slavenode = SlaveNode(channel)
        slavenode.run()
    """)
    channel = PickleChannel(channel)
    basetemp = None
    if gateway.spec.popen:
        popenbase = config.ensuretemp("popen")
        basetemp = py.path.local.make_numbered_dir(prefix="slave-", 
            keep=0, rootdir=popenbase)
        basetemp = str(basetemp)
    channel.send((config, basetemp))
    return channel
Example #9
0
def install_slave(gateway, config):
    channel = gateway.remote_exec(source="""
        import os, sys 
        sys.path.insert(0, os.getcwd()) 
        from py.__.test.dist.mypickle import PickleChannel
        from py.__.test.dist.txnode import SlaveNode
        channel = PickleChannel(channel)
        slavenode = SlaveNode(channel)
        slavenode.run()
    """)
    channel = PickleChannel(channel)
    basetemp = None
    if gateway.spec.popen:
        popenbase = config.ensuretemp("popen")
        basetemp = py.path.local.make_numbered_dir(prefix="slave-",
                                                   keep=0,
                                                   rootdir=popenbase)
        basetemp = str(basetemp)
    channel.send((config, basetemp))
    return channel
Example #10
0
 def test_popen_with_various_methods(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         channel.receive()
     """)
     channel = PickleChannel(channel)
     assert not channel.isclosed()
     assert not channel._getremoteerror()
     channel.send(2)
     channel.waitclose(timeout=2)
Example #11
0
 def test_send_concurrent(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         from py.__.test.dist.testing.test_mypickle import A
         l = [A() for i in range(10)]
         channel.send(l)
         other_l = channel.receive() 
         channel.send((l, other_l))
         channel.send(channel.receive())
         channel.receive()
     """)
     channel = PickleChannel(channel)
     l = [A() for i in range(10)]
     channel.send(l)
     other_l = channel.receive()
     channel.send(other_l)
     ret = channel.receive()
     assert ret[0] is other_l
     assert ret[1] is l 
     back = channel.receive()
     assert other_l is other_l 
     channel.send(None)
Example #12
0
 def setup(self, out=None):
     if out is None:
         out = py.io.TerminalWriter()
     if hasattr(self, 'gateway'):
         raise ValueError("already have gateway %r" % self.gateway)
     self.trace("setting up slave session")
     old = self.config.topdir.chdir()
     try:
         self.gateway = self.initgateway()
     finally:
         old.chdir()
     channel = self.gateway.remote_exec(source="""
         from py.__.test.dist.mypickle import PickleChannel
         from py.__.test.looponfail.remote import slave_runsession
         channel = PickleChannel(channel)
         config, fullwidth, hasmarkup = channel.receive()
         slave_runsession(channel, config, fullwidth, hasmarkup) 
     """,
                                        stdout=out,
                                        stderr=out)
     channel = PickleChannel(channel)
     channel.send((self.config, out.fullwidth, out.hasmarkup))
     self.trace("set up of slave session complete")
     self.channel = channel
Example #13
0
 def test_popen_with_newchannel(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         newchannel = channel.receive()
         newchannel.send(42)
     """)
     channel = PickleChannel(channel)
     newchannel = self.gw.newchannel()
     channel.send(newchannel)
     channel.waitclose()
     res = newchannel.receive()
     assert res == 42
Example #14
0
def test_config__setstate__wired_correctly_in_childprocess(testdir):
    from py.__.test.dist.mypickle import PickleChannel
    gw = py.execnet.PopenGateway()
    channel = gw.remote_exec("""
        import py
        from py.__.test.dist.mypickle import PickleChannel
        channel = PickleChannel(channel)
        config = channel.receive()
        assert py.test.config.pluginmanager.comregistry == py._com.comregistry, "comregistry wrong"
    """)
    channel = PickleChannel(channel)
    config = testdir.parseconfig()
    channel.send(config)
    channel.waitclose()  # this will potentially raise
    gw.exit()
Example #15
0
 def test_popen_with_callback(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         from py.__.test.dist.testing.test_mypickle import A
         a1 = A()
         a1.hello = 10
         channel.send(a1)
         a2 = channel.receive()
         channel.send(a2 is a1)
     """)
     channel = PickleChannel(channel)
     queue = py.std.Queue.Queue()
     channel.setcallback(queue.put)
     a_received = queue.get(timeout=TESTTIMEOUT)
     assert isinstance(a_received, A)
     assert a_received.hello == 10
     channel.send(a_received)
Example #16
0
 def test_popen_with_callback_with_endmarker_and_unpickling_error(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         from py.__.test.dist.testing.test_mypickle import A
         a1 = A()
         channel.send(a1)
         channel.send(a1)
     """)
     channel = PickleChannel(channel)
     queue = py.std.Queue.Queue()
     a = channel.receive()
     channel._ipickle._unpicklememo.clear()
     channel.setcallback(queue.put, endmarker=-1)
     next = queue.get(timeout=TESTTIMEOUT)
     assert next == -1
     error = channel._getremoteerror()
     assert isinstance(error, UnpickleError)
Example #17
0
 def test_popen_send_instance(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         from py.__.test.dist.testing.test_mypickle import A
         a1 = A()
         a1.hello = 10
         channel.send(a1)
         a2 = channel.receive()
         channel.send(a2 is a1)
     """)
     channel = PickleChannel(channel)
     a_received = channel.receive()
     assert isinstance(a_received, A)
     assert a_received.hello == 10
     channel.send(a_received)
     remote_a2_is_a1 = channel.receive()
     assert remote_a2_is_a1
Example #18
0
 def test_send_concurrent(self):
     channel = self.gw.remote_exec("""
         from py.__.test.dist.mypickle import PickleChannel
         channel = PickleChannel(channel)
         from py.__.test.dist.testing.test_mypickle import A
         l = [A() for i in range(10)]
         channel.send(l)
         other_l = channel.receive() 
         channel.send((l, other_l))
         channel.send(channel.receive())
         channel.receive()
     """)
     channel = PickleChannel(channel)
     l = [A() for i in range(10)]
     channel.send(l)
     other_l = channel.receive()
     channel.send(other_l)
     ret = channel.receive()
     assert ret[0] is other_l
     assert ret[1] is l
     back = channel.receive()
     assert other_l is other_l
     channel.send(None)