diff options
| author | Ryan Williams <breath@alum.mit.edu> | 2010-10-08 13:17:25 -0700 |
|---|---|---|
| committer | Ryan Williams <breath@alum.mit.edu> | 2010-10-08 13:17:25 -0700 |
| commit | 80e879386b22aa4c3fc4ff333a75dd867e6b3417 (patch) | |
| tree | b42f490cf6a8c0a1e4584c0ed8c9dd18961a4252 /eventlet/tpool.py | |
| parent | d1ef6f39e7a14d347e7caec498b2e6b178994b11 (diff) | |
| download | eventlet-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.py | 5 |
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() |
