(you responded off-list, which isn't the way these mailing lists work. So I'm pasting your message back to the list, with my response at the end)

Aaron Hoover wrote:
<snip>

But as soon as you have two threads doing "busy work," instead of them getting 50% each, the threading overhead goes way up, and you spend much of your time just deciding what not to do next.

Yeah, I had briefly read some grumblings regarding the GIL, but naively assumed it wouldn't bite me too badly.


And it gets enormously worse than that when there are more than one CPU available (eg. multicore).

Well, I'm running on a MacBook Pro, so count me in for that multicore performance degradation!



Many people have concluded that (in Python) much of what threads are used for should be done with processes.

Presumably you're referring to the processing module (pre 2.6 - multiprocessing in 2.6)? Do you have any canonical references or example code for using processing in the producer/consumer type paradigm I'm trying to use in my application. Specially, do you know if it's possible for processes to post wx events that can be handled by the main GUI thread?


Thanks for the help.

Cheers,
Aaron
Actually, I was thinking of the subprocess module (introduced in 2.4). But the multiprocessing module would be useful if you were porting threading code to a process model.

The real point is the distinction between threads and separate processes. If the processes are separate, then the only time synchronization is needed is when they communicate with each other, or with other shared services. So on a multicore system they each run at full tilt till they communicate.

There are tons of ways to communicate between processes, though you can't do the simple variable sharing that threads can (sometimes) get away with. I would normally point you to queues, but there a number of possibilities. And since the one process is running a GUI event loop, you might want to piggyback on the OS capability to post events between processes. The code might end up OS-dependent, but I'd bet the overhead will be minimal. What is your target operating system?

Your numbers in the original message make me nervous; sending an event between processes (or even threads) every 0.5 millisecond is impossible. But I think you might have been confusing bytes and packets.

There could very well be multiprocess support in wxPython. I'd check there first, before re-inventing the wheel. Presumably you know of the wxPython news group, hosted on Google groups?

DaveA
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to