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

Unified Diff: gsd_generate_index/gsd_generate_index.py

Issue 3336002: Fixing up error handling in workers. (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/
Patch Set: '' Created 9 years, 9 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: gsd_generate_index/gsd_generate_index.py
===================================================================
--- gsd_generate_index/gsd_generate_index.py (revision 77689)
+++ gsd_generate_index/gsd_generate_index.py (working copy)
@@ -58,7 +58,7 @@
fields = {}
fields['size'] = FixupSize(re.search('\tObject size:\t([0-9]+)\n',
p_stdout).group(1))
- fields['md5'] = re.search('\tMD5:\t([^\n]+)\n', p_stdout).group(1)
+ fields['md5'] = re.search('\t(MD5|Etag):\t([^\n]+)\n', p_stdout).group(2)
fields['date'] = re.search('\tLast mod:\t([^\n]+)\n', p_stdout).group(1)
return fields
@@ -140,11 +140,11 @@
print '%s -- updated index' % path
-def IndexWorker(index_list, mutex, directories, objects, options):
+def IndexWorker(index_list, errors, mutex, directories, objects, options):
while True:
# Pluck out one index to work on, or quit if no more work left.
mutex.acquire()
- if not len(index_list):
+ if not index_list:
mutex.release()
return
d = index_list.pop(0)
@@ -152,7 +152,13 @@
# Find just this directories children.
children = [o for o in objects if posixpath.dirname(o) == d]
# Generate it.
- GenerateIndex(d, children, directories, options)
+ try:
+ GenerateIndex(d, children, directories, options)
+ except Exception, e:
+ mutex.acquire()
+ errors.push(e)
+ print str(e)
+ mutex.release()
def GenerateIndexes(path, options):
@@ -177,8 +183,9 @@
if not options.path or options.path.startswith(i)]
# Spawn workers
mutex = threading.Lock()
+ errors = []
workers = [threading.Thread(target=IndexWorker,
- args=(index_list, mutex,
+ args=(index_list, errors, mutex,
directories, objects, options))
for _ in range(0, NUM_THREADS)]
# Start threads.
@@ -187,6 +194,8 @@
# Wait for them to finish.
for w in workers:
w.join()
+ if errors:
+ return 2
return 0
« 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