Handle ctrl-C and timeouts for Fuchsia test symbolization.
Handle ctrl-C and timeouts for Fuchsia test symbolization. Currently the symbolization worker processes fight over who gets to receive SIGINT when the user presses ctrl-C during symbolization. This change makes the parent process, the one that spawned the children, solely responsible for receiving the signal and killing the child processes. R: sergeyu@chromium.org Bug: 740201 Change-Id: I76721d18dda35a8d5b28ace24687c07ea0f68b87 Reviewed-on: https://chromium-review.googlesource.com/578747 Commit-Queue: Kevin Marshall <kmarshall@chromium.org> Reviewed-by: Wez <wez@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#489035} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 9d6ed67929770fd6541ac6bd82904ae1610fe745
This commit is contained in:
Родитель
4e3cd7e1ec
Коммит
e84a0ee25d
|
@ -12,6 +12,7 @@ import argparse
|
|||
import multiprocessing
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
@ -20,6 +21,7 @@ import tempfile
|
|||
DIR_SOURCE_ROOT = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||
SDK_ROOT = os.path.join(DIR_SOURCE_ROOT, 'third_party', 'fuchsia-sdk')
|
||||
SYMBOLIZATION_TIMEOUT_SECS = 10
|
||||
|
||||
|
||||
def RunAndCheck(dry_run, args):
|
||||
|
@ -200,8 +202,27 @@ def SymbolizeEntry(entry):
|
|||
|
||||
|
||||
def ParallelSymbolizeBacktrace(backtrace):
|
||||
# Disable handling of SIGINT during sub-process creation, to prevent
|
||||
# sub-processes from consuming Ctrl-C signals, rather than the parent
|
||||
# process doing so.
|
||||
saved_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||
p = multiprocessing.Pool(multiprocessing.cpu_count())
|
||||
return p.imap(SymbolizeEntry, backtrace)
|
||||
|
||||
# Restore the signal handler for the parent process.
|
||||
signal.signal(signal.SIGINT, saved_sigint_handler)
|
||||
|
||||
symbolized = []
|
||||
try:
|
||||
result = p.map_async(SymbolizeEntry, backtrace)
|
||||
symbolized = result.get(SYMBOLIZATION_TIMEOUT_SECS)
|
||||
if not symbolized:
|
||||
return []
|
||||
except multiprocessing.TimeoutError:
|
||||
return ['(timeout error occurred during symbolization)']
|
||||
except KeyboardInterrupt: # SIGINT
|
||||
p.terminate()
|
||||
|
||||
return symbolized
|
||||
|
||||
|
||||
def main():
|
||||
|
|
Загрузка…
Ссылка в новой задаче