This extra stop complexity is no longer needed

This commit is contained in:
Jean-Paul Calderone 2020-12-09 10:57:02 -05:00
parent 179f0bb9ec
commit 74c3990456

View File

@ -5,7 +5,6 @@ __all__ = [
"on_stdout", "on_stdout",
"on_stdout_and_stderr", "on_stdout_and_stderr",
"on_different", "on_different",
"wait_for_exit",
] ]
import os import os
@ -19,7 +18,6 @@ from eliot import (
) )
from twisted.internet.error import ( from twisted.internet.error import (
ProcessDone,
ProcessTerminated, ProcessTerminated,
ProcessExitedAlready, ProcessExitedAlready,
) )
@ -29,9 +27,6 @@ from twisted.internet.interfaces import (
from twisted.python.filepath import ( from twisted.python.filepath import (
FilePath, FilePath,
) )
from twisted.python.runtime import (
platform,
)
from twisted.internet.protocol import ( from twisted.internet.protocol import (
Protocol, Protocol,
ProcessProtocol, ProcessProtocol,
@ -180,7 +175,7 @@ class CLINodeAPI(object):
raise raise
@log_call_deferred(action_type="test:cli-api:stop") @log_call_deferred(action_type="test:cli-api:stop")
def stop(self, protocol): def stop(self):
return self.stop_and_wait() return self.stop_and_wait()
@log_call_deferred(action_type="test:cli-api:stop-and-wait") @log_call_deferred(action_type="test:cli-api:stop-and-wait")
@ -210,20 +205,3 @@ class CLINodeAPI(object):
stopping = self.stop_and_wait() stopping = self.stop_and_wait()
stopping.addErrback(self._check_cleanup_reason) stopping.addErrback(self._check_cleanup_reason)
return stopping return stopping
class _WaitForEnd(ProcessProtocol, object):
def __init__(self, ended):
self._ended = ended
def processEnded(self, reason):
if reason.check(ProcessDone):
self._ended.callback(None)
else:
self._ended.errback(reason)
def wait_for_exit():
ended = Deferred()
protocol = _WaitForEnd(ended)
return protocol, ended