Improve logging and ease debugging.
While trying to fix all the multithreading issues...
R=dpranke@chromium.org
BUG=
TEST=
Review URL: http://codereview.chromium.org/8135007
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@104026 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index 2402519..405f493 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -247,7 +247,7 @@
return new_fileobj
-def MakeFileAnnotated(fileobj):
+def MakeFileAnnotated(fileobj, include_zero=False):
"""Creates a file object clone to automatically prepends every line in worker
threads with a NN> prefix."""
if hasattr(fileobj, 'output_buffers'):
@@ -265,9 +265,11 @@
def annotated_write(out):
index = getattr(threading.currentThread(), 'index', None)
if index is None:
- # Undexed threads aren't buffered.
- new_fileobj.old_annotated_write(out)
- return
+ if not include_zero:
+ # Unindexed threads aren't buffered.
+ new_fileobj.old_annotated_write(out)
+ return
+ index = 0
new_fileobj.lock.acquire()
try:
@@ -557,7 +559,7 @@
self._flush_terminated_threads()
if (not self.queued and not self.running or
self.jobs == len(self.running)):
- # No more worker threads or can't queue anything.
+ logging.debug('No more worker threads or can\'t queue anything.')
break
# Check for new tasks to start.
@@ -644,7 +646,7 @@
"""One thread to execute one WorkItem."""
def __init__(self, item, index, args, kwargs):
threading.Thread.__init__(self, name=item.name or 'Worker')
- logging.info(item.name)
+ logging.info('_Worker(%s) reqs:%s' % (item.name, item.requirements))
self.item = item
self.index = index
self.args = args
@@ -652,7 +654,7 @@
def run(self):
"""Runs in its own thread."""
- logging.debug('running(%s)' % self.item.name)
+ logging.debug('_Worker.run(%s)' % self.item.name)
work_queue = self.kwargs['work_queue']
try:
self.item.run(*self.args, **self.kwargs)
@@ -661,7 +663,7 @@
logging.info('Caught exception in thread %s' % self.item.name)
logging.info(str(sys.exc_info()))
work_queue.exceptions.put(sys.exc_info())
- logging.info('Task %s done' % self.item.name)
+ logging.info('_Worker.run(%s) done' % self.item.name)
work_queue.ready_cond.acquire()
try: