-
Notifications
You must be signed in to change notification settings - Fork 55
task.sleep doesn't sleep long enough (in a class?) #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note: The task.sleep(1) is just to make sure this runs later than everything else. I have quite a few pyscripts running that generate output. This sleep just makes sure it's at the end of the startup log spam. |
I tried that in both Jupyter and a
|
I just updated to the latest I'll test it with the full app again and see if it's behaving as expected now. Thanks! |
Sounds good. BTW, you could make
|
Excellent! I wasn't sure if pyscript would see the triggers if I did it that way. I need to grok more of ast and global contexts to really get what pyscript is doing. It GREAT in this context because it's allowing pyscript to take away a lot of the "boilerplate" code that would otherwise be required, making it really easy to use. And making it so people don't HAVE to grok ast, global contexts, or any of that to be able to use it for easier automation writing (because, in my opinion, python is FAR easier than Home Assistant template code, even for a non-programmer, for anything other than the most simple of cases. But, the other day I tried using, for instance, state_trigger as though it were a regularly defined decorator only to find that it is not. Something like this...
... doesn't work, for instance. Also trying to use other decorators... like...
... doesn't work either. Other things, too. Like this interesting bit:
|
As far as task.sleep() working as it should goes, my simple test in the OP of this issue is still working fine. However, in the full application, it's still breaking weirdly. Either I have a bug that I'm just NOT seeing, or The application is an "occupancy manager". You provide sensors and events that indicate when the room is occupied, and it manages indicating the room as occupied when it is, waiting for a certain "timeout" and then marks the room as unoccupied. It's hard to write test cases for, because it's all based on timers (using If you're willing, I can get the not-quite-working code up on github and you can take a look and see if you can find the issue. |
In prepping the code to share, I saw something that might enter a race condition on task.unique(). So I've reworked that bit to see if that was the issue. I won't have time to mess with it over the next few days, but I'll look again on Friday and see if it resolved the issues I was having. |
I believe the issue I'm having here is a result of the issue described in #33 . Closing this. |
This script:
This log:
Notice the timestamps, long did not sleep long enough.
The text was updated successfully, but these errors were encountered: