Ejemplo n.º 1
0
def test_pid_file_lock_context_manager(tmpdir):
    pid_file = Path(tmpdir) / "test.pid"

    assert not store.have_lock("%s" % pid_file)

    with daemon.pid_file_lock(pid_file):
        assert store.have_lock("%s" % pid_file)
Ejemplo n.º 2
0
def test_pid_file_lock_context_manager_exception(tmpdir):
    pid_file = Path(tmpdir) / "test.pid"

    assert not store.have_lock("%s" % pid_file)
    try:
        with daemon.pid_file_lock(pid_file):
            assert store.have_lock("%s" % pid_file)
            raise MKGeneralException("bla")
    except MKGeneralException:
        pass

    assert not store.have_lock("%s" % pid_file)