upload_symbols: fix race w/failed_queue usage
The current code might leave elements in the queue depending on the
code flow (emtpy returns True because elements are in flight and not
yet registered). Instead, require a sentinel None value in this func
as that should never show up normally (we always expect strings).
BUG=chromium:349043
TEST=`./scripts/upload_symbols_unittest.py` no longer flakes locally
Change-Id: I420e8df0a40e8c0e486f61e9e8b05a9c07182044
Reviewed-on: https://chromium-review.googlesource.com/189410
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/upload_symbols.py b/scripts/upload_symbols.py
index ec48ed5..dd4638f 100644
--- a/scripts/upload_symbols.py
+++ b/scripts/upload_symbols.py
@@ -476,6 +476,8 @@
def WriteQueueToFile(listing, queue, relpath=None):
"""Write all the items in |queue| to the |listing|.
+ Note: The queue must have a sentinel None appended to the end.
+
Args:
listing: Where to write out the list of files.
queue: The queue of paths to drain.
@@ -485,8 +487,10 @@
return
with cros_build_lib.Open(listing, 'wb+') as f:
- while not queue.empty():
+ while True:
path = queue.get()
+ if path is None:
+ return
if relpath:
path = os.path.relpath(path, relpath)
f.write('%s\n' % path)
@@ -617,8 +621,13 @@
break
sym_paths = []
- while not failed_queue.empty():
- sym_paths.append(failed_queue.get())
+ failed_queue.put(None)
+ while True:
+ sym_path = failed_queue.get()
+ if sym_path is None:
+ break
+ sym_paths.append(sym_path)
+
if sym_paths:
cros_build_lib.Warning('retrying %i symbols', len(sym_paths))
if counters.upload_limit is not None:
@@ -633,6 +642,7 @@
# If the user has requested it, save all the symbol files that we failed to
# upload to a listing file. This should help with recovery efforts later.
+ failed_queue.put(None)
WriteQueueToFile(failed_list, failed_queue, breakpad_dir)
if dedupe_queue: