Use the new cleanup helper for process cleanup
This removes some repetition of logic and switches to a more aggressive cleanup approach.
This commit is contained in:
parent
cec31e6e5a
commit
e511adbf63
|
@ -6,6 +6,7 @@ from time import sleep
|
|||
from os import mkdir, listdir
|
||||
from os.path import join, exists
|
||||
from tempfile import mkdtemp, mktemp
|
||||
from functools import partial
|
||||
|
||||
from twisted.python.procutils import which
|
||||
from twisted.internet.error import (
|
||||
|
@ -23,6 +24,7 @@ from util import (
|
|||
_ProcessExitedProtocol,
|
||||
_create_node,
|
||||
_run_node,
|
||||
_cleanup_twistd_process,
|
||||
)
|
||||
|
||||
|
||||
|
@ -107,11 +109,7 @@ def flog_gatherer(reactor, temp_dir, flog_binary, request):
|
|||
pytest_twisted.blockon(twistd_protocol.magic_seen)
|
||||
|
||||
def cleanup():
|
||||
try:
|
||||
twistd_process.signalProcess('TERM')
|
||||
pytest_twisted.blockon(twistd_protocol.exited)
|
||||
except ProcessExitedAlready:
|
||||
pass
|
||||
_cleanup_twistd_process(twistd_process, twistd_protocol.exited)
|
||||
|
||||
flog_file = mktemp('.flog_dump')
|
||||
flog_protocol = _DumpOutputProtocol(open(flog_file, 'w'))
|
||||
|
@ -180,14 +178,7 @@ log_gatherer.furl = {log_furl}
|
|||
intro_dir,
|
||||
),
|
||||
)
|
||||
|
||||
def cleanup():
|
||||
try:
|
||||
process.signalProcess('TERM')
|
||||
pytest_twisted.blockon(protocol.exited)
|
||||
except ProcessExitedAlready:
|
||||
pass
|
||||
request.addfinalizer(cleanup)
|
||||
request.addfinalizer(partial(_cleanup_twistd_process, process, protocol.exited))
|
||||
|
||||
pytest_twisted.blockon(protocol.magic_seen)
|
||||
return process
|
||||
|
|
|
@ -3,6 +3,7 @@ import time
|
|||
from os import mkdir
|
||||
from os.path import exists, join
|
||||
from StringIO import StringIO
|
||||
from functools import partial
|
||||
|
||||
from twisted.internet.defer import Deferred, succeed
|
||||
from twisted.internet.protocol import ProcessProtocol
|
||||
|
@ -144,13 +145,7 @@ def _run_node(reactor, node_dir, request, magic_text):
|
|||
)
|
||||
process.exited = protocol.exited
|
||||
|
||||
def cleanup():
|
||||
try:
|
||||
process.signalProcess('TERM')
|
||||
pytest_twisted.blockon(protocol.exited)
|
||||
except ProcessExitedAlready:
|
||||
pass
|
||||
request.addfinalizer(cleanup)
|
||||
request.addfinalizer(partial(_cleanup_twistd_process, process, protocol.exited))
|
||||
|
||||
# we return the 'process' ITransport instance
|
||||
# XXX abusing the Deferred; should use .when_magic_seen() or something?
|
||||
|
|
Loading…
Reference in New Issue