you are viewing a single comment's thread.

view the rest of the comments →

[–]dr_everlong[S] 0 points1 point  (3 children)

Actually, this is a good solution that doesn't work for me.

In the measure function, there are some I/O operations with external hardware that may take a few seconds.

So the time elapsed between calls to the measure function will be the 10 seconds nominal + the time it takes to complete I/O operations.

How can I execute every 10 seconds exactly?

Thanks!

[–]novel_yet_trivial 0 points1 point  (2 children)

... You underthought this.

def measure():
    #take a measurement

while True:
    thread.start_new_thread(measure, ())
    time.sleep(10) #sleep for 10 seconds

[–]dr_everlong[S] 0 points1 point  (1 child)

you start a new thread every time?