def test_stopping_children_of_stopped_process():
    """
    Check that children exiting between listing and killing are ignored.

    Given:
        Executor is running and it's process spawn children,
        and we requested it's stop, and it's stopped
    When:
        At the time of the check for subprocesses they're still active,
        but before we start killing them, they are already dead.
    Then:
        We ignore and skip OsError indicates there's no such process.
    """
    # pylint: disable=protected-access, missing-docstring
    def raise_os_error(*_, **__):

        os_error = OSError()
        os_error.errno = errno.ESRCH
        raise os_error

    def processes_with_env_mock(*_, **__):
        return [1]

    with patch(
            'mirakuru.base.processes_with_env', new=processes_with_env_mock
    ), patch('os.kill', new=raise_os_error):
        executor = SimpleExecutor(SLEEP_300)
        executor._kill_all_kids(executor._sig_stop)
Beispiel #2
0
def test_stopping_children_of_stopped_process():
    """
    Check that children exiting between listing and killing are ignored.

    Given:
        Executor is running and it's process spawn children,
        and we requested it's stop, and it's stopped
    When:
        At the time of the check for subprocesses they're still active,
        but before we start killing them, they are already dead.
    Then:
        We ignore and skip OsError indicates there's no such process.
    """

    # pylint: disable=protected-access, missing-docstring
    def raise_os_error(*_, **__):

        os_error = OSError()
        os_error.errno = errno.ESRCH
        raise os_error

    def processes_with_env_mock(*_, **__):
        return [1]

    with patch("mirakuru.base.processes_with_env",
               new=processes_with_env_mock), patch("os.kill",
                                                   new=raise_os_error):
        executor = SimpleExecutor(SLEEP_300)
        executor._kill_all_kids(executor._stop_signal)
Beispiel #3
0
def test_stopping_children_of_stopped_process():
    """
    Check that children exiting between listing and killing are ignored.

    Given:
        Executor is running and it's process spawn children,
        and we requested it's stop, and it's stopped
    When:
        At the time of the check for subprocesses they're still active,
        but before we start killing them, they are already dead.
    Then:
        We ignore and skip OsError indicates there's no such process.
    """
    def raise_os_error(*args, **kwargs):
        os_error = OSError()
        os_error.errno = errno.ESRCH
        raise os_error

    def processes_with_env_mock(*args, **kwargs):
        return [1]

    with patch('mirakuru.base.processes_with_env',
               new=processes_with_env_mock), patch('os.kill',
                                                   new=raise_os_error):
        executor = SimpleExecutor(sleep_300)
        executor._kill_all_kids(executor._sig_stop)