Skip to content
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

Question about ThreadPoolExecutor #2025

Open
ssppest opened this issue Apr 3, 2024 · 1 comment
Open

Question about ThreadPoolExecutor #2025

ssppest opened this issue Apr 3, 2024 · 1 comment

Comments

@ssppest
Copy link

ssppest commented Apr 3, 2024

  • gevent version: 20.10.2
  • Python version: cPython 3.9
  • Operating System: macOS 14.3.1(M3)

Description:

Some question

  1. What is the difference between concurrent.futures.ThreadPoolExecutor and gevent.threadpool.ThreadPoolExecutor?
  2. Will gevent affect the child threads started by the concurrent.futures.ThreadPoolExecutor?(In other words, have the child threads started after monkey patch all also been patched?)
  3. How to determine if the current thread is affected by gevent?
@embray
Copy link

embray commented Jun 3, 2024

My general understanding of this is you should continue to use concurrent.futures.ThreadPoolExecutor for IO-bound threads--so long as threading is patched it will use greenlets instead of threads in the threadpool. In principle the underlying Queue and synchronization primitives (e.g. Semaphore) are patched to, so it should "just work"

Whereas, if you are using ThreadPoolExecutor for CPU-bound threads it won't work cooperatively with greenlets, so such code should be replaced (or patched) to use gevent's ThreadPoolExecutor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants