B
bart_nessux
I need a script to call several functions at the same time. How does one
call more than one function simultaneously?
call more than one function simultaneously?
bart_nessux said:I need a script to call several functions at the same time. How does one
call more than one function simultaneously?
I need a script to call several functions at the same time. How does one
call more than one function simultaneously?
Cameron said: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.
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.
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.
Bart Nessux said: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.
i just added my first thread to a wxpython program today. simple. inbart_nessux said:I need a script to call several functions at the same time. How does one
call more than one function 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.
I mean it to mean: at the *exact* same time... concurrently. Like runners
starting a race together.
Specific to Python.
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.
I mean it to mean: at the *exact* same time... concurrently. Like runners
starting a race together.
Bart said:Cameron Laird wrote:
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.
I mean it to mean: at the *exact* same time... concurrently. Like runners
starting a race together.
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,
Grant said:Not sure what you mean by "todays machines", but on a
Pentium-class machine running Linux, you get approx 1us
resolution with calls to time.time():
Keep in mind the difference between "accuracy" and
"resolution" (or "precision").
I think Knio is probably right that, unless you are running on
a realtime OS, you won't be able to guarantee anything better
than 1ms accuracy, and quite probably not even that.
Grant said:I do.
Not only do you get 1us resolution, you get packet timestamp
_accuracy_ to well under 1ms according to tests I've run
comparing packet timestamps against an oscilloscope trace.
Delta-T accuracy of calls to time() are accurate to 1us as
well. Absolute accuracy depends on how you set your system
clock. Running NTP with in-kernel FLL control of the system
tick will generally allow you to maintain absolute accuracies
of under 100us.
Under Linux, I can guarantee you the answer you get back from
time.time() is accurate to 1us. However, it is a multitasking
system, and there are other things running. While it's easy to
_determine_ exactly when you called time.time(), it's difficult
to _control_ the point in time when you call time.time(). When
your task does get a chance to run, and you do get to call
time.time(), you'll generally get a result accurate to 1us.
If I do a busy-wait loop with nothing else running, I've been
able to accurately measure pulsewidths of a few microseconds
under Linux using the gettimeofday() call (which I believe is
what time.time() calls.
As soon as there are other ready tasks, the accuracy of the
measurement quickly deteriorates to tens of millisconds due to
scheduling latencies.
The network guy in me says that pinging 4 machines at the same time from 1Bart Nessux said: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.
Grant said:I do.
Not only do you get 1us resolution, you get packet timestamp
_accuracy_ to well under 1ms according to tests I've run
comparing packet timestamps against an oscilloscope trace.
[snip other technical details]
As soon as there are other ready tasks, the accuracy of the
measurement quickly deteriorates to tens of millisconds due to
scheduling latencies.
The last sentence is really the whole point. The OP needs
to be aware that the accuracy *cannot* be *guaranteed*
to better than "tens of milliseconds", overall, regardless
of the "accuracy" of the clock tick or the resolution of
anything...
The notes on timeit.py are helpful in this respect, however:
taking the shortest result of repeated measurements is a
pretty good way to get an "accurate" number, most of the
time. The other, higher results represent the interference
of all those other tasks which will tend to run as you
try to take measurements.
-Peter
Grant said:Knio wrote: said: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...
Not sure what you mean by "todays machines", but on a
Pentium-class machine running Linux, you get approx 1us
resolution with calls to time.time():
[snip]
Bart Nessux said:I mean it to mean: at the *exact* same time... concurrently. Like runners
starting a race together.
At 2004-04-30T23:43:37Z said: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.
Bart said:I need to ping 4 hosts at exactly the same time from the same machine (I
plan to timestamp the pings)
I mean it to mean: at the *exact* same time.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.