Skip to content

variables undefined after task.sleep #37

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

Closed
dlashua opened this issue Oct 11, 2020 · 7 comments
Closed

variables undefined after task.sleep #37

dlashua opened this issue Oct 11, 2020 · 7 comments

Comments

@dlashua
Copy link
Contributor

dlashua commented Oct 11, 2020

This issue is dependent on ... something else ... that I can't quite figure out. It doesn't happen every time, so a simplified test doesn't show the issue immediately.

In a Class Method:

        start_sleep = time.monotonic()
        task.sleep(self.timeout)
        elapsed_sleep = time.monotonic() - start_sleep

Error:

2020-10-11 06:14:12 ERROR (MainThread) [custom_components.pyscript.apps.occupancy_manager.inner_occupied_states] Exception in <apps.occupancy_manager.inner_occupied_states> line 224:
            elapsed_sleep = time.monotonic() - start_sleep
                                               ^
NameError: name 'start_sleep' is not defined
@dlashua
Copy link
Contributor Author

dlashua commented Oct 11, 2020

This appears to be happening outside of a class as well.

@craigbarratt
Copy link
Member

So far I'm not able to replicate this. Could this case be connected to reload?

@dlashua
Copy link
Contributor Author

dlashua commented Oct 11, 2020

Perhaps? I just restarted Home Assistant (to add full traceback). I will need to restart pyscript once when it starts (because for some reason my YAML defined apps don't load without a restart, I've yet to debug that and report). But, aside from that one restart, I'll leave it be for a bit and see if it happens again.

@craigbarratt
Copy link
Member

craigbarratt commented Oct 11, 2020

It looks like the new config flow PR #31 breaks the initial config values, which requires a reload. Haven't had a chance to look at that yet.

@dlashua
Copy link
Contributor Author

dlashua commented Oct 12, 2020

Ah, glad you found that. I still hadn't gotten around to writing a proper, concise test case for it. Thanks!

@dlashua
Copy link
Contributor Author

dlashua commented Oct 12, 2020

The original issue (variables undefined after task.sleep) seems to have been resolved. I will open a new issue if it presents again.

Leaving this open for now in case you're using it to track "failure to load initial config values".

@craigbarratt
Copy link
Member

The config loading is being addressed in #39.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants