зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1299216 - Wait for process exit first before checking for crashes. r=automatedtester
MozReview-Commit-ID: 8U48dNHoFmi --HG-- extra : rebase_source : 263ef1c801f6020fabacb36fdfbbed0690396ae1
This commit is contained in:
Родитель
d4392e6af8
Коммит
339324700f
|
@ -4,8 +4,6 @@
|
|||
|
||||
from functools import wraps
|
||||
import socket
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
|
||||
def _find_marionette_in_args(*args, **kwargs):
|
||||
|
@ -21,25 +19,13 @@ def do_process_check(func):
|
|||
"""Decorator which checks the process status after the function has run."""
|
||||
@wraps(func)
|
||||
def _(*args, **kwargs):
|
||||
m = _find_marionette_in_args(*args, **kwargs)
|
||||
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except IOError as e:
|
||||
exc, val, tb = sys.exc_info()
|
||||
crashed = False
|
||||
|
||||
try:
|
||||
crashed = m.check_for_crash()
|
||||
except Exception:
|
||||
# don't want to lose the original exception
|
||||
traceback.print_exc()
|
||||
|
||||
# In case of socket failures force a shutdown of the application
|
||||
if type(e) in (socket.error, socket.timeout) or crashed:
|
||||
m.handle_socket_failure(crashed)
|
||||
|
||||
raise exc, val, tb
|
||||
except (socket.error, socket.timeout):
|
||||
# In case of socket failures which will also include crashes of the
|
||||
# application, make sure to handle those correctly.
|
||||
m = _find_marionette_in_args(*args, **kwargs)
|
||||
m.handle_socket_failure()
|
||||
|
||||
return _
|
||||
|
||||
|
|
|
@ -540,7 +540,6 @@ class Marionette(object):
|
|||
|
||||
CONTEXT_CHROME = 'chrome' # non-browser content: windows, dialogs, etc.
|
||||
CONTEXT_CONTENT = 'content' # browser content: iframes, divs, etc.
|
||||
DEFAULT_CRASH_TIMEOUT = 10
|
||||
DEFAULT_SOCKET_TIMEOUT = 60
|
||||
DEFAULT_STARTUP_TIMEOUT = 120
|
||||
DEFAULT_SHUTDOWN_TIMEOUT = 65 # Firefox will kill hanging threads after 60s
|
||||
|
@ -794,11 +793,8 @@ class Marionette(object):
|
|||
|
||||
return crash_count > 0
|
||||
|
||||
def handle_socket_failure(self, crashed=False):
|
||||
"""Handle socket failures for the currently running instance.
|
||||
|
||||
:param crashed: Optional flag which indicates that the process has been crashed,
|
||||
and no further socket checks have to be performed. Defaults to False.
|
||||
def handle_socket_failure(self):
|
||||
"""Handle socket failures for the currently running application instance.
|
||||
|
||||
If the application crashed then clean-up internal states, or in case of a content
|
||||
crash also kill the process. If there are other reasons for a socket failure,
|
||||
|
@ -808,26 +804,26 @@ class Marionette(object):
|
|||
if self.instance:
|
||||
exc, val, tb = sys.exc_info()
|
||||
|
||||
# If the content process crashed, Marionette forces the application to shutdown.
|
||||
if crashed:
|
||||
returncode = self.instance.runner.wait(timeout=self.DEFAULT_CRASH_TIMEOUT)
|
||||
# Somehow the socket disconnected. Give the application some time to shutdown
|
||||
# itself before killing the process.
|
||||
returncode = self.instance.runner.wait(timeout=self.DEFAULT_SHUTDOWN_TIMEOUT)
|
||||
|
||||
if returncode is None:
|
||||
message = ('Process killed because the connection to Marionette server is '
|
||||
'lost. Check gecko.log for errors')
|
||||
self.quit()
|
||||
else:
|
||||
# If Firefox quit itself check if there was a crash
|
||||
crash_count = self.check_for_crash()
|
||||
|
||||
if crash_count > 0:
|
||||
if returncode == 0:
|
||||
message = 'Content process crashed'
|
||||
else:
|
||||
message = 'Process crashed (Exit code: {returncode})'
|
||||
self.delete_session(send_request=False, reset_session_id=True)
|
||||
else:
|
||||
message = 'Process has been unexpectedly closed (Exit code: {returncode})'
|
||||
|
||||
else:
|
||||
# Somehow the socket disconnected. Give the application some time to shutdown
|
||||
# itself before killing the process.
|
||||
returncode = self.instance.runner.wait(timeout=self.DEFAULT_SHUTDOWN_TIMEOUT)
|
||||
if returncode is None:
|
||||
self.quit()
|
||||
message = ('Process killed because the connection to Marionette server is '
|
||||
'lost. Check gecko.log for errors')
|
||||
else:
|
||||
message = 'Process has been closed (Exit code: {returncode})'
|
||||
self.delete_session(send_request=False, reset_session_id=True)
|
||||
|
||||
if exc:
|
||||
|
|
Загрузка…
Ссылка в новой задаче