gevent python3.7 + ThreadPoolExecutor block main thread

Created on 11 Jul 2018  路  6Comments  路  Source: gevent/gevent

  • gevent version: 1.3.4
  • Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] downloaded from python.org
  • Operating System: Windows-10-10.0.16299-SP0

Description:

gevent + python3.7 + ThreadPoolExecutor will block main thread forever while running future.result(). seems like something about _thread.allocate_lock.acquire.

only python3.7 hit that issue

python3.6+ubuntu18.04 + gevent 1.3.4 runs ok

python3.7+ubuntu18.04 + gevent 1.3.4 runs bad

What I've run:

from gevent import monkey

monkey.patch_all()

from concurrent.futures import ThreadPoolExecutor
import requests

pool = ThreadPoolExecutor()

task = pool.submit(requests.get, "http://python.org")
task.add_done_callback(lambda r: print(r.result(), 'done'))
print(task.result())

output:

and then blocking...............

All 6 comments

please try #1248

@wwqgtxx thanks very much, close this issue for duplicate.

Sure enough, on 3.7, ThreadPoolExecuter was changed to use queue.SimpleQueue; on 3.6 it uses queue.Queue.

@jamadden thank you for answering, will gevent do that trick in the future versions?

@ClericPy See #1253. I was on the fence about having gevent do that patch (it's never patched queue before) but this example convinced me that it was the right thing.

waiting for the wonderful lib's updating ^-^

Was this page helpful?
0 / 5 - 0 ratings