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.
This commit is contained in:
3
AUTHORS
3
AUTHORS
@@ -62,4 +62,5 @@ Thanks To
|
||||
* Favo Yang, twisted hub patch
|
||||
* Schmir, patch that fixes readline method with chunked encoding in wsgi.py, advice on patcher
|
||||
* Slide, for open-sourcing gogreen
|
||||
* Holger Krekel, websocket example small fix
|
||||
* Holger Krekel, websocket example small fix
|
||||
* mikepk, debugging MySQLdb/tpool issues
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user