Skip to content

Commit

Permalink
Merge pull request #328 from masayukig/remove-callwhenprocfinishes
Browse files Browse the repository at this point in the history
Remove CallWhenProcFinishes class in utils.py
  • Loading branch information
mtreinish authored Apr 28, 2022
2 parents d239d25 + 3e49e5d commit 2191ea8
Showing 1 changed file with 0 additions and 41 deletions.
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

0 comments on commit 2191ea8

Please sign in to comment.