Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20723

Re: asynchronous downloading

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: asynchronous downloading
References <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2>
Date 2012-02-23 03:46 -0800
Message-ID <7x4nuhlqmf.fsf@ruckus.brouhaha.com> (permalink)
Organization Nightsong/Fort GNOX

Show all headers | View raw


Plumo <richardbp@gmail.com> writes:
> What do you recommend? 

Threads.

> And why is there poor support for asynchronous execution?

The freenode #python crowd seems to hate threads and prefer twisted,
which seems to have the features you want and probably handles very
large #'s of connections better than POSIX threads do.  But I find the
whole event-driven model to be an annoying abstraction inversion and
threads to be simpler, so I've stayed with threads.  I keep hearing
boogieman stories about the evil hazards of race conditions etc. but
none of that stuff has ever happened to me (yet) as far as I can tell.
The main thing is to avoid sharing mutable data between threads to the
extent that you can.  Keep the threads isolated from each other except
for communication through Queues and not too much can go wrong.  The
last program I wrote had around 20 threads and one or two condition
variables and I don't think any significant bugs resulted from that.

FWIW, the Erlang language is built around the above concept, it uses
super-lightweight userland threads so it can handle millions of them
concurrently, and it's used successfully for ultra-high-reliability
phone switches and similar applications that are not allowed to fail, so
it must be doing something right.

There are a few schemes like Camaelia (sp?) implementing concurrency
with Python generators or coroutines, but I think they're not widely
used, and Python coroutines are kind of crippled because they don't
carry any stack below their entry point.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

asynchronous downloading Plumo <richardbp@gmail.com> - 2012-02-22 22:58 -0800
  Re: asynchronous downloading Justin Ezequiel <justin.mailinglists@gmail.com> - 2012-02-22 23:25 -0800
  Re: asynchronous downloading Mark Hammond <mhammond@skippinet.com.au> - 2012-02-23 22:20 +1100
  Re: asynchronous downloading Paul Rubin <no.email@nospam.invalid> - 2012-02-23 03:46 -0800
    Re: asynchronous downloading Plumo <richardbp@gmail.com> - 2012-02-23 16:28 -0800
  Re: asynchronous downloading Richard Baron Penman <richardbp@gmail.com> - 2012-02-24 00:50 +1100
  Re: asynchronous downloading Giampaolo Rodolà <g.rodola@gmail.com> - 2012-02-23 18:31 +0100
    Re: asynchronous downloading Plumo <richardbp@gmail.com> - 2012-02-23 17:10 -0800
    Re: asynchronous downloading Plumo <richardbp@gmail.com> - 2012-02-23 17:10 -0800
      Re: asynchronous downloading Fayaz Yusuf Khan <fayaz.yusuf.khan@gmail.com> - 2012-02-23 18:31 -0800
      Re: asynchronous downloading Giampaolo Rodolà <g.rodola@gmail.com> - 2012-02-24 10:03 +0100
      Re: asynchronous downloading Richard Baron Penman <richardbp@gmail.com> - 2012-02-26 08:44 +1100

csiph-web