How to use the execnet.multi.Group function in execnet

To help you get started, we’ve selected a few execnet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pytest-dev / execnet / testing / test_multi.py View on Github external
def test_basic_group(self, monkeypatch):
        import atexit

        atexitlist = []
        monkeypatch.setattr(atexit, "register", atexitlist.append)
        group = Group()
        assert atexitlist == [group._cleanup_atexit]
        exitlist = []
        joinlist = []

        class PseudoIO:
            def wait(self):
                pass

        class PseudoSpec:
            via = None

        class PseudoGW:
            id = "9999"
            _io = PseudoIO()
            spec = PseudoSpec()
github pytest-dev / execnet / testing / test_multi.py View on Github external
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
github pytest-dev / execnet / testing / test_multi.py View on Github external
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]
github pytest-dev / execnet / testing / test_multi.py View on Github external
def test_group_default_spec(self):
        group = Group()
        group.defaultspec = "not-existing-type"
        py.test.raises(ValueError, group.makegateway)
github pytest-dev / execnet / testing / test_multi.py View on Github external
def test_terminate_with_proxying(self):
        group = Group()
        group.makegateway("popen//id=master")
        group.makegateway("popen//via=master//id=worker")
        group.terminate(1.0)
github pytest-dev / execnet / execnet / multi.py View on Github external
termreply = workerpool.spawn(termfunc)
        try:
            termreply.get(timeout=timeout)
        except IOError:
            killfunc()

    replylist = []
    for termfunc, killfunc in list_of_paired_functions:
        reply = workerpool.spawn(termkill, termfunc, killfunc)
        replylist.append(reply)
    for reply in replylist:
        reply.get()
    workerpool.waitall(timeout=timeout)


default_group = Group()
makegateway = default_group.makegateway
set_execmodel = default_group.set_execmodel
github pytest-dev / execnet / testing / test_multi.py View on Github external
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()
github pytest-dev / execnet / testing / test_multi.py View on Github external
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) == ""