New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gevent python3.7 + ThreadPoolExecutor block main thread #1251

Closed
ClericPy opened this Issue Jul 11, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@ClericPy

ClericPy commented Jul 11, 2018

  • 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:

<Response [200]> done

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

@ClericPy ClericPy changed the title from gevent python3.7 + ThreadPoolExecutor block main thread forever. to gevent python3.7 + ThreadPoolExecutor block main thread Jul 11, 2018

@wwqgtxx

This comment has been minimized.

wwqgtxx commented Jul 11, 2018

please try #1248

@ClericPy

This comment has been minimized.

ClericPy commented Jul 11, 2018

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

@ClericPy ClericPy closed this Jul 11, 2018

@jamadden

This comment has been minimized.

Member

jamadden commented Jul 11, 2018

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

jamadden added a commit that referenced this issue Jul 11, 2018

jamadden added a commit that referenced this issue Jul 11, 2018

@ClericPy

This comment has been minimized.

ClericPy commented Jul 11, 2018

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

@jamadden

This comment has been minimized.

Member

jamadden commented Jul 11, 2018

@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.

@ClericPy

This comment has been minimized.

ClericPy commented Jul 11, 2018

waiting for the wonderful lib's updating ^-^

jamadden added a commit that referenced this issue Jul 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment