How to delay until a next increment of time occurs ?

Terry Reedy tjreedy at udel.edu
Wed Nov 13 16:25:21 EST 2019


On 11/13/2019 9:02 AM, R.Wieser wrote:

> I'm writing some code to toggle a pin on a Raspberry Pi, and would like to
> have that happen at (multiples of) 300 uSec increments.

If you were looking at increments of multiple milleseconds, such as 1/60 
== 16.6..., I would suggest using tkinter's root.after, with a minimum 
non-zero delay of 1 millesecond.  I believe one can do better with async 
as its default loop runs a bit faster and there is a C-coded replacement 
available, which should be faster yet.  It has delay-until(time) as well 
as delay-for(interval).

-- 
Terry Jan Reedy



More information about the Python-list mailing list