diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 707572ed1fbb59ead3b8be91969bf73ebfc535db..6237cbe93a5253fddae646f417693f7013a5e389 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ test_job: # Create environment - pacman -Syu --noconfirm - pacman -S --noconfirm grep python - - pacman -S --noconfirm python-pythondialog python-pytest python-pytest-runner python-pytest-cov python-pylint python-isort mypy pylama python-mccabe python-requests + - pacman -S --noconfirm python-pytest python-pytest-runner python-pytest-cov python-pylint python-isort mypy pylama python-mccabe # Run tests - python setup.py test # Artifacts diff --git a/src/forkedsubprocess/__init__.py b/src/forkedsubprocess/__init__.py index 78ea6aa99021fabee54a9d8098d4836001249b7e..d43956377282134200502a104b4ffbf4b041c3be 100644 --- a/src/forkedsubprocess/__init__.py +++ b/src/forkedsubprocess/__init__.py @@ -1,10 +1,30 @@ +# Copyright (C) 2019, AllWorldIT. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + """Forked subprocesses support for Python.""" import subprocess import threading from typing import IO, Any, Callable, Dict, List, Optional -__version__ = '1.0.3' +__version__ = '1.0.4' # Define our callback types InputCallback = Callable[[], str] @@ -271,15 +291,19 @@ class ForkedSubprocess: raise ForkedSubprocessNotRunningException('wait() was called on a subprocess which is not running') # Stop writer - self._stdin_writer.stop() + if self._stdin_writer: + self._stdin_writer.stop() # Wait for process exit self._process.wait() # Wait for threads to read data and exit - self._stdin_writer.wait() - self._stdout_reader.wait() - self._stderr_reader.wait() + if self._stdin_writer: + self._stdin_writer.wait() + if self._stdout_reader: + self._stdout_reader.wait() + if self._stderr_reader: + self._stderr_reader.wait() return self._process.returncode