Exemplo n.º 1
0
    def test_remote_exec_args(self):
        group = Group()
        group.makegateway('popen')

        def fun(channel, arg):
            channel.send(arg)
        mch = group.remote_exec(fun, arg=1)
        result = mch.receive_each()
        assert result == [1]
Exemplo n.º 2
0
    def test_remote_exec_args(self):
        group = Group()
        group.makegateway('popen')

        def fun(channel, arg):
            channel.send(arg)
        mch = group.remote_exec(fun, arg=1)
        result = mch.receive_each()
        assert result == [1]
Exemplo n.º 3
0
 def test_group_id_allocation(self):
     group = Group()
     specs = [XSpec("popen"), XSpec("popen//id=hello")]
     group.allocate_id(specs[0])
     group.allocate_id(specs[1])
     gw = group.makegateway(specs[1])
     assert gw.id == "hello"
     gw = group.makegateway(specs[0])
     assert gw.id == "gw0"
     #py.test.raises(ValueError, group.allocate_id, XSpec("popen//id=hello"))
     group.terminate()
Exemplo n.º 4
0
 def test_group_id_allocation(self):
     group = Group()
     specs = [XSpec("popen"), XSpec("popen//id=hello")]
     group.allocate_id(specs[0])
     group.allocate_id(specs[1])
     gw = group.makegateway(specs[1])
     assert gw.id == "hello"
     gw = group.makegateway(specs[0])
     assert gw.id == "gw0"
     # py.test.raises(ValueError,
     #    group.allocate_id, XSpec("popen//id=hello"))
     group.terminate()
Exemplo n.º 5
0
 def test_group_ordering_and_termination(self):
     group = Group()
     group.makegateway("popen//id=3")
     group.makegateway("popen//id=2")
     group.makegateway("popen//id=5")
     gwlist = list(group)
     assert len(gwlist) == 3
     idlist = [x.id for x in gwlist]
     assert idlist == list("325")
     print(group)
     group.terminate()
     print(group)
     assert not group
     assert repr(group) == "<Group []>"
Exemplo n.º 6
0
 def test_group_ordering_and_termination(self):
     group = Group()
     group.makegateway("popen//id=3")
     group.makegateway("popen//id=2")
     group.makegateway("popen//id=5")
     gwlist = list(group)
     assert len(gwlist) == 3
     idlist = [x.id for x in gwlist]
     assert idlist == list('325')
     print (group)
     group.terminate()
     print (group)
     assert not group
     assert repr(group) == "<Group []>"
Exemplo n.º 7
0
 def test_group_PopenGateway(self):
     group = Group()
     gw = group.makegateway("popen")
     assert list(group) == [gw]
     assert group[0] == gw
     assert len(group) == 1
     group._cleanup_atexit()
     assert not group._gateways
Exemplo n.º 8
0
 def test_group_PopenGateway(self):
     group = Group()
     gw = group.makegateway("popen")
     assert list(group) == [gw]
     assert group[0] == gw
     assert len(group) == 1
     group._cleanup_atexit()
     assert not group._gateways
Exemplo n.º 9
0
 def test_gateway_and_id(self):
     group = Group()
     gw = group.makegateway("popen//id=hello")
     assert group["hello"] == gw
     py.test.raises((TypeError, AttributeError), "del group['hello']")
     py.test.raises((TypeError, AttributeError), "group['hello'] = 5")
     assert 'hello' in group
     assert gw in group
     assert len(group) == 1
     gw.exit()
     assert 'hello' not in group
     py.test.raises(KeyError, "group['hello']")
Exemplo n.º 10
0
 def test_gateway_and_id(self):
     group = Group()
     gw = group.makegateway("popen//id=hello")
     assert group["hello"] == gw
     py.test.raises((TypeError, AttributeError), "del group['hello']")
     py.test.raises((TypeError, AttributeError), "group['hello'] = 5")
     assert 'hello' in group
     assert gw in group
     assert len(group) == 1
     gw.exit()
     assert 'hello' not in group
     py.test.raises(KeyError, "group['hello']")
Exemplo n.º 11
0
 def test_gateway_and_id(self):
     group = Group()
     gw = group.makegateway("popen//id=hello")
     assert group["hello"] == gw
     with pytest.raises((TypeError, AttributeError)):
         del group["hello"]
     with pytest.raises((TypeError, AttributeError)):
         group["hello"] = 5
     assert "hello" in group
     assert gw in group
     assert len(group) == 1
     gw.exit()
     assert "hello" not in group
     with pytest.raises(KeyError):
         _ = group["hello"]
Exemplo n.º 12
0
 def test_terminate_with_proxying(self):
     group = Group()
     group.makegateway("popen//id=master")
     group.makegateway("popen//via=master//id=worker")
     group.terminate(1.0)
Exemplo n.º 13
0
 def test_terminate_with_proxying(self):
     group = Group()
     group.makegateway('popen//id=master')
     group.makegateway('popen//via=master//id=slave')
     group.terminate(1.0)
Exemplo n.º 14
0
 def test_terminate_with_proxying(self):
     group = Group()
     group.makegateway('popen//id=master')
     group.makegateway('popen//via=master//id=slave')
     group.terminate(1.0)