Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CallWhenProcFinishes class in utils.py #328

Merged
merged 2 commits into from
Apr 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions stestr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,6 @@
from stestr import output


class CallWhenProcFinishes:
"""Convert a process object to trigger a callback when returncode is set.

This just wraps the entire object and when the returncode attribute access
finds a set value, calls the callback.
"""

def __init__(self, process, callback):
"""Adapt process

:param process: A subprocess.Popen object.
:param callback: The process to call when the process completes.
"""
self._proc = process
self._callback = callback
self._done = False

@property
def stdin(self):
return self._proc.stdin

@property
def stdout(self):
return self._proc.stdout

@property
def stderr(self):
return self._proc.stderr

@property
def returncode(self):
result = self._proc.returncode
if not self._done and result is not None:
self._done = True
self._callback()
return result

def wait(self):
return self._proc.wait()


def _iter_internal_streams(input_streams, stream_type):
streams = []
for in_stream in input_streams:
Expand Down