running functions

Gorlon the Impossible meatpodeye at yahoo.com
Fri Nov 18 01:55:10 CET 2005


On Thu, 17 Nov 2005 23:29:16 +0000, Tom Anderson
<twic at urchin.earth.li> wrote:

>On Wed, 16 Nov 2005, sjdevnull at yahoo.com wrote:
>
>> Gorlon the Impossible wrote:
>>
>>> Is it possible to run this function and still be able to do other 
>>> things with Python while it is running? Is that what threading is 
>>> about?
>>
>> Threading's a good answer if you really need to share all your memory. A 
>> multiprocess solution is probably preferrable, though it depends on the 
>> architecture.
>
>I'm really curious about this assertion, which both you and Ben Finney 
>make. Why do you think multiprocessing is preferable to multithreading?
>
>I've done a fair amount of threads programming, although in java rather 
>than python (and i doubt very much that it's less friendly in python than 
>java!), and i found it really fairly straightforward. Sure, if you want to 
>do complicated stuff, it can get complicated, but for this sort of thing, 
>it should be a doddle. Certainly, it seems to me, *far* easier than doing 
>anything involving multiple processes, which always seems like pulling 
>teeth to me.
>
>For example, his Impossibleness presumably has code which looks like this:
>
>do_a_bunch_of_midi(do, re, mi)
>do_something_else(fa, so, la)
>
>All he has to do to get thready with his own bad self is:
>
>import threading
>threading.Thread(do_a_bunch_of_midi, (do, re, mi)).start()
>do_something_else(fa, so, la)
>
>How hard is that? Going multiprocess involves at least twice as much code, 
>if not ten times more, will have lower performance, and will make future 
>changes - like interaction between the two parallel execution streams - 
>colossally harder.
>
>tom

I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...



More information about the Python-list mailing list