summaryrefslogtreecommitdiff
path: root/eventlet/tpool.py
diff options
context:
space:
mode:
authorRyan Williams <breath@alum.mit.edu>2010-10-08 13:17:25 -0700
committerRyan Williams <breath@alum.mit.edu>2010-10-08 13:17:25 -0700
commit80e879386b22aa4c3fc4ff333a75dd867e6b3417 (patch)
treeb42f490cf6a8c0a1e4584c0ed8c9dd18961a4252 /eventlet/tpool.py
parentd1ef6f39e7a14d347e7caec498b2e6b178994b11 (diff)
downloadeventlet-80e879386b22aa4c3fc4ff333a75dd867e6b3417.tar.gz
Fixing hang when importing a module that makes a tpooled MySQLdb connection, thanks to mikepk for getting to the bottom of this. Still needs a unit test.
Diffstat (limited to 'eventlet/tpool.py')
-rw-r--r--eventlet/tpool.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/eventlet/tpool.py b/eventlet/tpool.py
index 553b22e..3281cbc 100644
--- a/eventlet/tpool.py
+++ b/eventlet/tpool.py
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import imp
import os
import sys
@@ -97,8 +98,10 @@ def execute(meth,*args, **kwargs):
global _threads
setup()
# if already in tpool, don't recurse into the tpool
+ # also, call functions directly if we're inside an import lock, because
+ # if meth does any importing (sadly common), it will hang
my_thread = threading.currentThread()
- if my_thread in _threads:
+ if my_thread in _threads or imp.lock_held():
return meth(*args, **kwargs)
cur = greenthread.getcurrent()