내가 Python3에 프로젝트를 포팅하고 있는데 내가 실행 해요에서 하위 프로세스를 호출 할 때 [WinError 6] 핸들이 잘못되었습니다 : Windows에서 기본적으로 파이썬 3.6에OSError : Windows에서 예기치 않은 오류로 파이썬 3.6
,
d:\temp\backpack\venv\myvenv_py3.6\lib\site-packages\git\cmd.py:1011: in _call_process
return self.execute(call, **exec_kwargs)
d:\temp\backpack\venv\myvenv_py3.6\lib\site-packages\git\cmd.py:732: in execute
**subprocess_kwargs
D:\temp\cpython-3.6.3\Lib\subprocess.py:611: in __init__
_cleanup()
D:\temp\cpython-3.6.3\Lib\subprocess.py:220: in _cleanup
res = inst._internal_poll(_deadstate=sys.maxsize)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <subprocess.Popen object at 0x0000000004FD53C8>
_deadstate = 9223372036854775807
_WaitForSingleObject = <built-in function WaitForSingleObject>
_WAIT_OBJECT_0 = 0, _GetExitCodeProcess = <built-in function GetExitCodeProcess>
def _internal_poll(self, _deadstate=None,
_WaitForSingleObject=_winapi.WaitForSingleObject,
_WAIT_OBJECT_0=_winapi.WAIT_OBJECT_0,
_GetExitCodeProcess=_winapi.GetExitCodeProcess):
"""Check if child process has terminated. Returns returncode
attribute.
This method is called by __del__, so it can only refer to objects
in its local scope.
"""
_log.debug('proc._internal_poll self.pid=%s self._handle=%s self.returncode=%s self=%s', self.pid, self._handle, self.returncode, self)
if self.returncode is None:
> if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
E OSError: [WinError 6] The handle is invalid
D:\temp\cpython-3.6.3\Lib\subprocess.py:1051: OSError
subprocess
호출에서 생성되는 위치는 중요하지 않습니다 (이 프로젝트에 많이가 GitPython
패키지 및 plumbum
에서의) : 프로세스가 하위 프로세스로 생성 될 때마다, 나는이 예외가 .
이 실행은 build script
venv/Scripts/coverage run -m pytest -v tests/
을 호출하는이 우산 아래에서 발생합니다. 항상
- 을 : 항상 는 윈도우 7 가상 머신에 :(
- 를 전달 내 윈도우 7 PC에
- : 그러나 나는 또한 재생의 관점에서
venv/Scripts/pytest --cov=mypackage --cov-config .coveragerc - tests/
와pytest-cov
을 시도했습니다 - 항상 이 실패 [
<build script>
이venv/Scripts/coverage run -m pytest
호출] 때 는 실패 때coverage run -m pytest
venv - 에서 직접 호출하지만
pytest
가 VIRTUALENV 항상 이 상관없이하여<build script>
경우 실패하는 윈 10 PC에
- : 그러나 나는 또한 재생의 관점에서
- 에서 직접 호출 할 때 항상 는을 전달합니다 호출, 또는
coverage
또는pytest
경우 venv
내가 지금까지 가지고이 StackOverflow의 스레드에서입니다 한 유일한 단서에서 직접 호출 : https://stackoverflow.com/a/43975118 그리고 더 정확히 말하자면, 모듈의 _cleanup
메서드와 관련된 유용한 점을 지적하는 첫 번째 대답의 주석입니다.
이 질문에 대한 답변이 제공되었다 : https://stackoverflow.com/a/40108817/501074이 문제를 해결하지 못했습니다. –
서브 프로세스를 사용하는 코드가 실제로 어떻게 생겼습니까? –