4 ms·
This is indeed awesome and I've used it in several applications. I forget though: does this use a single global interpreter or do the additional threads use th
by gsibble 14y ago
This is indeed awesome and I've used it in several applications.
I forget though: does this use a single global interpreter or do the additional threads use their own interpreters?
- hythloday 14y agoThreads inherit the process's interpreter (which is how they share the GIL). Contrast to multiprocessing, which spawns a new interpreter and communicates with it via a python IPC, such as multiprocessing.Queue, which shares the interface with queue.Queue or the slightly clumsy multiprocessing.Value class: from multiprocessing import Process, Value def f(n): n.value = 3.1415927 num = Value('d', 0.0) p = Process(target=f, args=(num)) p.start() p.join() print num.value # 3.1415927
- Luyt 14y agoAh, args should be a tuple: p = Process(target=f, args=(num,))