Reduce the chances for gclient to throw an exception in subprocess module.

Python standard library is not thread safe. Work around it by leaking a bit.
The problem is particularly visible on python 2.4.

TEST=none
BUG=60623

Review URL: http://codereview.chromium.org/4465001

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@65048 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index d0fbb1e..5ab1ed5 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -1,16 +1,6 @@
-# Copyright 2009 Google Inc.  All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
 
 """Generic utils."""
 
@@ -28,6 +18,14 @@
 import xml.parsers.expat
 
 
+def hack_subprocess():
+  """subprocess functions may throw exceptions when used in multiple threads.
+
+  See http://bugs.python.org/issue1731717 for more information.
+  """
+  subprocess._cleanup = lambda: None
+
+
 class Error(Exception):
   """gclient exception class."""
   pass
@@ -573,6 +571,7 @@
   def __init__(self, jobs, progress):
     """jobs specifies the number of concurrent tasks to allow. progress is a
     Progress instance."""
+    hack_subprocess()
     # Set when a thread is done or a new item is enqueued.
     self.ready_cond = threading.Condition()
     # Maximum number of concurrent tasks.