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

Unified Diff: tools/findit/crash_utils.py

Issue 538383002: [Findit] Make Findit more robust. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Workaround python bug. Created 6 years, 3 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 | « tools/findit/common/http_client_local.py ('k') | tools/findit/findit_for_clusterfuzz.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/findit/crash_utils.py
diff --git a/tools/findit/crash_utils.py b/tools/findit/crash_utils.py
index 6be058b0823fa8f635b13090e169362a875d7b79..a3af854106a5d56aac52991fc0c2a959e8fb1fba 100644
--- a/tools/findit/crash_utils.py
+++ b/tools/findit/crash_utils.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import atexit
import cgi
import ConfigParser
import json
@@ -20,10 +21,39 @@ MAX_THREAD_NUMBER = 10
TASK_QUEUE = None
+def SignalWorkerThreads():
+ global TASK_QUEUE
+ if not TASK_QUEUE:
+ return
+
+ for i in range(MAX_THREAD_NUMBER):
+ TASK_QUEUE.put(None)
+
+ # Give worker threads a chance to exit.
+ # Workaround the harmless bug in python 2.7 below.
+ time.sleep(1)
+ print '%s is quitting' % threading.currentThread().name
+
+
+atexit.register(SignalWorkerThreads)
+
+
def Worker():
global TASK_QUEUE
while True:
- function, args, kwargs, result_semaphore = TASK_QUEUE.get()
stgao 2014/09/05 08:33:18 The exception is as below: Exception in thread wo
+ try:
+ task = TASK_QUEUE.get()
+ if not task:
+ print '%s is quitting' % threading.currentThread().name
stgao 2014/09/05 08:33:18 I will revert the print before committing. But I'd
+ return
+ except TypeError:
+ # According to http://bugs.python.org/issue14623, this is a harmless bug
+ # in python 2.7 which won't be fixed.
+ # The exception is raised on daemon threads when python interpreter is
+ # shutting down.
+ return
+
+ function, args, kwargs, result_semaphore = task
try:
function(*args, **kwargs)
except:
« no previous file with comments | « tools/findit/common/http_client_local.py ('k') | tools/findit/findit_for_clusterfuzz.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698