Python multiplexing is too hard (was: Network statistics program)

Cameron Laird claird at
Wed May 17 19:55:13 EDT 2000

In article <sZBU4.1751$%8.7965 at>,
Greg Fortune <gfor_ewu at> wrote:
>Right now, I'm just sending the output of the ping to a text file and then
>reading it from there.
>os.system('ping -t 1 > convertor_temp.txt')
>#Read input file and extract result
>#Store result
>  That circumvents the need for the select.  The only reason I've done this
>is because the os.system call will not return the output from the call (and
>I'm very new to this language as well as "real-world" programming <g>).  Is
>there another way (possibly the select you mentioned) to get the output from
>a call back to the program?  I need to use this on both Linux and Windows so
>I can't use the UNIX specific commands module.
>Cedric Adjih <adjih at> wrote in message
>news:8ftqtk$25a$1 at
>> You can use module time, function sleep:
>>   time.sleep(1.1) # sleep 1.1 seconds
>> Or if you are waiting for events or for a timeout, select
>> will be helpful:
>>[file desc list]..., timeOutInSeconds)
>> For instance if you are waiting for a ping reply.
>> -- Cedric

What's the really cool, idiomatic way to multiplex in Python?
I'm not happy with anything I do in this regard.

First, I recognize this is far afield from Mr. Fortune's
needs.  He's best served either by direct ICMP calls, or a
  os.popen("ping -c 1 ...").read()
which gives him all of what I understand he's after.  Mr.
Fortune, let me know if it's not obvious how this answers
your question, and I'll be more explicit.

Suppose, though, that he really did need multiplexing.  Is
there a tutorial I haven't noticed yet that models the Python
way to process (let's call them) stream-based events?  We can
put stuff in a thread, but that's a lot of mechanism; we can
select, but, gosh, isn't that the low-level error-prone OS
system-level programming Python's s'posed to transcend?  All
the Python code I've seen in this area just "has too many
notes".  It makes me think it's fragile.

Cameron Laird <claird at>

More information about the Python-list mailing list