netinvent / command_runner

Substitute for subprocess that handles all hassle that comes from different platform and python versions, and allows live stdout and stderr capture for background job/interactive GUI programming ;)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigate Python 2.7 os.kill permission error

deajan opened this issue · comments

______________________ test_standard_ping_with_encoding _______________________

    def test_standard_ping_with_encoding():
        """
        Test command_runner with a standard ping and encoding parameter
        """
        for method in methods:
            print('method={}'.format(method))
            exit_code, output = command_runner(PING_CMD, encoding=ENCODING, method=method)
            print(output)
>           assert exit_code == 0, 'Exit code should be 0 for ping command with method {}'.format(method)
E           AssertionError: Exit code should be 0 for ping command with method monitor
E           assert -253 == 0
E             --253
E             +0

tests\test_command_runner.py:105: AssertionError
---------------------------- Captured stdout call -----------------------------
method=monitor\nCommand "ping 127.0.0.1 -n 4" failed because of OS: [Error 5] Acc\u03a6s refus
------------------------------ Captured log call ------------------------------
ERROR    command_runner:__init__.py:243 No psutil module present. Can only kill direct pids, not child subtree.
ERROR    command_runner:__init__.py:306 Could not properly kill process with pid 119160: [Error 5] Accs refus
ERROR   \x1b[1m\x1b[31mERROR   \x1b[0m command_runner:__init__.py:243 No psutil module present. Can only kill direct pids, not child subtree.\n\x1b[1m\x1b[31mERROR   \x1b[0m command_runner:__init__.py:306 Could not properly kill process with pid 119160: [Error 5] Accs refus\n\x1b[1m\x1b[31mERROR   \x1b[0m command_runner:__init__.py:867 Command "ping 127.0.0.1 -n 4" failed because of OS: [Error 5] Acc\u03a6s refus
========================== 1 failed in 5.69 seconds ===========================

We still get this sporadic error from time to time where OS Permission deneid happens when we try to kill an existing process with os.kill(pid, 15) on Python 2.7.
The pid exists or else we would have [Error 87] Incorrect parameter

Need to investigate whether access is denied because some lock is on process.