Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: tools/telemetry/telemetry/page/shared_page_state.py

Issue 1066663002: Guarantee CleanUpAfterPage gets run even if CloseConnection fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/page/shared_page_state.py
diff --git a/tools/telemetry/telemetry/page/shared_page_state.py b/tools/telemetry/telemetry/page/shared_page_state.py
index 690e148e0538a350540bf336f13b8177ed792bb7..852247b1f5935db6d695dcc151fa733f72033cc5 100644
--- a/tools/telemetry/telemetry/page/shared_page_state.py
+++ b/tools/telemetry/telemetry/page/shared_page_state.py
@@ -85,16 +85,20 @@ class SharedPageState(shared_user_story_state.SharedUserStoryState):
def DidRunUserStory(self, results):
if self._finder_options.profiler:
self._StopProfiling(results)
- if self._current_tab and self._current_tab.IsAlive():
- self._current_tab.CloseConnections()
- self._test.CleanUpAfterPage(self._current_page, self._current_tab)
- if self._current_page.credentials and self._did_login_for_current_page:
- self.browser.credentials.LoginNoLongerNeeded(
- self._current_tab, self._current_page.credentials)
- if self._test.StopBrowserAfterPage(self.browser, self._current_page):
- self._StopBrowser()
- self._current_page = None
- self._current_tab = None
+ # We might hang while trying to close the connection, and need to guarantee
+ # the page will get cleaned up to avoid future tests failing in weird ways.
+ try:
+ if self._current_tab and self._current_tab.IsAlive():
+ self._current_tab.CloseConnections()
+ finally:
+ self._test.CleanUpAfterPage(self._current_page, self._current_tab)
+ if self._current_page.credentials and self._did_login_for_current_page:
+ self.browser.credentials.LoginNoLongerNeeded(
+ self._current_tab, self._current_page.credentials)
+ if self._test.StopBrowserAfterPage(self.browser, self._current_page):
+ self._StopBrowser()
+ self._current_page = None
+ self._current_tab = None
@property
def platform(self):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698