5

I know that Python 2.7 does not allow one to run multiple threads on different cores, and you need to use the multiprocessing module in order to achieve some degree of concurrency. I was looking at the concurrent.futures module in Python 3.4. Does using a ThreadPoolExecutor allow you to run different threads on different processes, or is it still bound by GIL constraints? If not, is there a way of running threads on different processors using Python 3.4?

For my use case, using multiple processes is absolutely not feasible.

dano
  • 91,354
  • 19
  • 222
  • 219
  • just curious - under what circumstances would multiple processes be absolutely unfeasible? – Roberto Jun 24 '14 at 23:51
  • Let's assume you're working on an embedded system with very little memory. It's not a very good idea to spawn multiple processes there, right? Although I agree that Python shouldn't be the language of choice either. It's just a small experiment that I am carrying out. – Diptesh Chatterjee Jun 25 '14 at 06:39

1 Answers1

5

No. ThreadPoolExector is just a class to help with scheduling work on multiple threads. All of the normal thread constraints still apply.

To clear up some confusion, threads will run on different processors / cores as the operating system chooses, they just won't run concurrently. The exception is that some C based functions release the GIL temporarily while performing actions not needing the lock.

tdelaney
  • 73,364
  • 6
  • 83
  • 116