I'm new to multiprocessing
I ran sample code for two “recommended” multiprocessing examples given in response to other stackoverflow multiprocessing questions. Here is an example of one (which I dare not run again!)
test2.py (powered by pydev)
import multiprocessing class MyFancyClass(object): def __init__(self, name): self.name = name def do_something(self): proc_name = multiprocessing.current_process().name print(proc_name, self.name) def worker(q): obj = q.get() obj.do_something() queue = multiprocessing.Queue() p = multiprocessing.Process(target=worker, args=(queue,)) p.start() queue.put(MyFancyClass('Fancy Dan'))
When I run this, my computer instantly slows down. It becomes gradually slower. After some time, I managed to enter the task manager to see MANY MANY python.exe on the process tab. after trying to complete the process on some, my mouse stopped moving. This was the second time I was forced to reboot.
I'm too scared to try a third example ...
works - Intel (R) Core (TM) i7 CPU 870 @ 2.93 GHz (8 processors), ~ 2.9 GHz on win7 64
If anyone knows what the problem is and can provide a VERY SIMPLE example of multiprocessing (send the string too multiprocessor, change it and send it for printing), I would be very grateful.
source share