Perspective, time.sleep vs later.py

Hi all,

So what would be better, time.sleep or later.py, on Perspective View. ( 8.0.13 and after)
a. for 1-3 seconds
b. for longer period, minutes, days etc

Thanks for your insight.

time.sleep should be avoided in basically every scenario - the only exception I would maybe give is a dedicated thread spawned by invokeAsynchronous. later.py technically hooks into an internal class, but the signature of that class is pretty unlikely to change, and, crucially, it does not require a thread to be kept sleeping.

3 Likes

I’m naturally biased, as the author of later.py. But see my rants on people using sleep():

http://forum.inductiveautomation.com/search?q=sleep%20%40pturmel

2 Likes

So in Perspective no invokeLater, noTimer, only time.sleep which should be avoided.

For the moment all we can say is Long Live Phil. :slight_smile:

1 Like

In an event-driven environment, I see use of sleep() as an indication that there’s a state machine that needs to be written, with regular timer calls to step it along.