Workaround a limitation in cygwin with Lock creation.
Reuse a common lock to reduce the number of locks created. Poor cygwin users.
R=dpranke@chromium.org
BUG=
TEST=
Review URL: http://codereview.chromium.org/8353010
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@106494 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index 0dcef9d..918b489 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -480,17 +480,14 @@
class WorkItem(object):
"""One work item."""
+ # On cygwin, creating a lock throwing randomly when nearing ~100 locks.
+ # As a workaround, use a single lock. Yep you read it right. Single lock for
+ # all the 100 objects.
+ lock = threading.Lock()
+
def __init__(self, name):
# A unique string representing this work item.
self._name = name
- try:
- self.lock = threading.Lock()
- except: # pylint: disable=W0702
- if sys.platform != 'cygwin':
- raise
- # On cygwin, it's throwing randomly. Hack and reuse the single
- # sys.stdout.lock. Yep you read it right. Single lock.
- self.lock = sys.stdout.lock
def run(self, work_queue):
"""work_queue is passed as keyword argument so it should be