calling functions at the same time
Knio
knio at knio.h4xn3t.net
Sat May 1 03:59:12 EDT 2004
Bart Nessux wrote:
> Cameron Laird wrote:
>
>
>>In article <c6udda$qpv$1 at solaris.cc.vt.edu>,
>>bart_nessux <bart_nessux at hotmail.com> wrote:
>>
>>>I need a script to call several functions at the same time. How does one
>>>call more than one function simultaneously?
>>>
>>>
>>>
>>
>>This has several smart-alecky answers, including "you don't",
>>and "with co-routines". The best way you can help yourself is
>>to describe a concrete situation where your (Python?) script
>>has a need to call even two functions simultaneously.
>
>
> I need to ping 4 hosts at exactly the same time from the same machine (I
> plan to timestamp the pings) to test and measure network conditions over
> different routes to different hosts. Putting all the ping hosts in a list
> and looping through it is not a fair or balanced way to do this because of
> the time differences.
>
>
>
>
>>It turns
>>out "simultaneously" has a plethora of meanings, and you're the
>>only one in a position to get others to understand which you
>>have in mind.
>
>
> I mean it to mean: at the *exact* same time... concurrently. Like runners
> starting a race together.
>
>
>>It'll also help to know whether you mean "function" as specific
>>to the Python language, or more abstractly, as a unit of useful
>>accomplishment.
>
>
> Specific to Python.
You can't get greater then 1ms accuracy when measuring a time on todays
machines, and that will be less when measuring time over a network...
calling 4 ping functions one after the other will complete in much less
then 1ms (assuming its asynchronous, or threaded). So, even if you could
manage to send 4 packets at *exactly* the same time, it would be no more
accurate.
not sure how your planning to ping the hosts... check out the asyncore
and threading modules.
More information about the Python-list
mailing list