(sort of) deterministic timing in Python
Hendrik van Rooyen
mail at microcorp.co.za
Tue Aug 14 10:30:55 EDT 2007
"John Fisher" <jo.....cast.net> wrote:
import time
period_time = TIME_CONSTANT # The time of a period in seconds - 0.001 is a
millisec
>mark start time
start_time = time.time()
>start event
> event finishes
event_time = time.time() - start_time
wait_time = period_time-event_time
>count time until next interval
if wait_time > 0:
time.sleep(wait_time)
>start second event…
that should (sort of) do it.
HTH - Hendrik
More information about the Python-list
mailing list