How to use the mirakuru.PidExecutor function in mirakuru

To help you get started, we’ve selected a few mirakuru 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 ClearcodeHQ / mirakuru / tests / executors / test_pid_executor.py View on Github external
def test_start_and_wait():
    """Test if the executor will await for the process to create a file."""
    process = f'bash -c "sleep 2 && touch {FILENAME} && sleep 10"'
    with PidExecutor(process, FILENAME, timeout=5) as executor:
        assert executor.running() is True

    # check proper __str__ and __repr__ rendering:
    assert 'PidExecutor' in repr(executor)
    assert process in str(executor)
github ClearcodeHQ / mirakuru / tests / executors / test_pid_executor.py View on Github external
def test_fail_if_other_executor_running():
    """Test raising AlreadyRunning exception when port is blocked."""
    process = f'bash -c "sleep 2 && touch {FILENAME} && sleep 10"'
    executor = PidExecutor(process, FILENAME)
    executor2 = PidExecutor(process, FILENAME)

    with executor:

        assert executor.running() is True

        with pytest.raises(AlreadyRunning):
            executor2.start()
github ClearcodeHQ / mirakuru / tests / executors / test_pid_executor.py View on Github external
def test_fail_if_other_executor_running():
    """Test raising AlreadyRunning exception when port is blocked."""
    process = f'bash -c "sleep 2 && touch {FILENAME} && sleep 10"'
    executor = PidExecutor(process, FILENAME)
    executor2 = PidExecutor(process, FILENAME)

    with executor:

        assert executor.running() is True

        with pytest.raises(AlreadyRunning):
            executor2.start()
github ClearcodeHQ / mirakuru / tests / executors / test_pid_executor.py View on Github external
def test_empty_filename(pid_file):
    """Check whether an exception is raised if an empty FILENAME is given."""
    with pytest.raises(ValueError):
        PidExecutor(SLEEP, pid_file)
github ClearcodeHQ / mirakuru / tests / executors / test_pid_executor.py View on Github external
def test_timeout_error():
    """Check if timeout properly expires."""
    executor = PidExecutor(SLEEP, FILENAME, timeout=1)

    with pytest.raises(TimeoutExpired):
        executor.start()

    assert executor.running() is False
github ClearcodeHQ / mirakuru / tests / executors / test_pid_executor.py View on Github external
def test_if_file_created():
    """Check whether the process really created the given file."""
    assert os.path.isfile(FILENAME) is False
    executor = PidExecutor(SLEEP, FILENAME)
    with executor:
        assert os.path.isfile(FILENAME) is True