Re: good book on multithreaded programming with Python
In article <fvlmrvgoee208s 99e0ksoerih99f7 rps6m@4ax.com>,
Fernando Rodriguez <frr@easyjob.ne t> wrote:[color=blue]
>Hi,
>
>Any recommendation for a good book on multithreaded programming with Python?[/color]
Re: good book on multithreaded programming with Python
claird@lairds.c om (Cameron Laird) writes:
[color=blue]
> Do you *really* want
> concurrent programming with Python
> or
> programming with Python's threads
> or
> Python programming with low-level threads[/color]
Yes, please.
I'm not the OP, but right now I'm porting a C/C++ program from Win32
to Python on Linux and OS-X. The original program relies quite heavily
on threading.
A book that covers all the above options would really help me figure
out the optimal approach to this project. I'm especially concerned
that the GIL will make a pure-Python approach risky, since this
application involves a fair abount of network data and real-time data
processing.
As it is, I have to read several discussions of each
approach. Unfortunately, on this project learning time is not billable
time. (Fortunately, experimentation is billable, and with Python,
learning and experimenting are often one and the same...)
Nick
--
# sigmask || 0.2 || 20030107 || public domain || feed this to a python
print reduce(lambda x,y:x+chr(ord(y )-1),' Ojdl!Wbshjti!=o bwAcboefstobudi/psh?')
GIL risky for threading and networking? (was Re: good book onmultithreaded programming with Python)
Nick Vargish wrote:[color=blue]
>
> A book that covers all the above options would really help me figure
> out the optimal approach to this project. I'm especially concerned
> that the GIL will make a pure-Python approach risky, since this
> application involves a fair abount of network data and real-time data
> processing.[/color]
What risk concerns you with respect to doing networking and "real-time"
processing using Python, given that the GIL exists? Would you have the
same concerns if you didn't even know of the existence of the GIL?
(I believe you should have those concerns, but just because you're
trying to use an unfamiliar environment for something fairly intensive,
not because it's Python specifically, or the GIL.)
I do lots of "network data and real-time data processing" using Python
and have not encountered any particular difficulties, and certainly none
that can be attributed to the existence of the GIL.
Is this a case of fear arising out of ignorance? If so, why not just
write a quick test/experiment that will remove or affirm your concern?
It would be trivial to write a program that created a dozen threads,
each doing processing that would take five seconds of dedicated CPU time,
and a network thread which grabs data from an external source as it
becomes available, at whatever rate you need. You'll likely find out
that with an adequate CPU, everything will work just as you need it to,
and that the only difference between the old program and the new is that
the Python-based one consumes a lot more CPU time for the same data...
If you have specific reasons for the concern, please provide them so
we can address them. The GIL certainly doesn't get in the way of
soft real-time work in any way that's significant.
Re: good book on multithreaded programming with Python
A good book on writing multi-threaded applications is "Concurrent
Programming in Java" by Doug Lea. The focus is more on multi-threaded
applications than on Java.
Re: GIL risky for threading and networking? (was Re: good book on multithreaded programming with Python)
Peter Hansen <peter@engcorp. com> writes:
[color=blue]
> Is this a case of fear arising out of ignorance?[/color]
Most probably. On the other hand, I probably wouldn't have spoken up
if I hadn't seen the post I replied to.
I am planning on as pure Python an approach as possible, and have been
from the start. I certainly wasn't trying to borrow trouble from the
future or optimize too early in development.
[color=blue]
> If you have specific reasons for the concern, please provide them so
> we can address them.[/color]
This is the attitude that makes me tell my boss(es) that I get better
support from the open source community than I ever could from a
commercial outfit. Thanks!
[color=blue]
> The GIL certainly doesn't get in the way of
> soft real-time work in any way that's significant.[/color]
I'm going to proceed with that expectation, thanks again.
Nick
--
# sigmask || 0.2 || 20030107 || public domain || feed this to a python
print reduce(lambda x,y:x+chr(ord(y )-1),' Ojdl!Wbshjti!=o bwAcboefstobudi/psh?')
Comment