Skip to content

Add supervisor function to poll autoreload status #5352

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
wants to merge 1 commit into from

Conversation

mscreations
Copy link

This adds a function to supervisor to check what the current autoreload status is from code.py.

@dhalbert
Copy link
Collaborator

dhalbert commented Sep 15, 2021

In your code, do you not know if supervisor.disable_autoreload() has been called already or not? Could you explain the use case? Thanks.

@mscreations
Copy link
Author

So the code I'm using launches different apps depending on what keys are held down at boot so at any given time on code.py entry, auto-reload may or may not be known. Specifically, I wish to toggle autoreload on a button press which requires knowledge of the current status to call the correct function. I thought of creating a toggle function instead, but as long as I can determine the current status it's trivial to call the correct function.

Copy link
Collaborator

@microdev1 microdev1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @mscreations. I have one suggestion, I think it might be better if autoreload_enabled is done as a property.

@dhalbert
Copy link
Collaborator

Thanks for the PR @mscreations. I have one suggestion, I think it might be better if autoreload_enabled is done as a property.

We don't have module properties, so it would need to be moved to supervisor.runtime (the sole instance of Runtime). We could then have a single autoreload property to query or set. But it would be a breaking change. We might consider moving other things to there as well if we made this change.

@tannewt
Copy link
Member

tannewt commented Sep 16, 2021

You may be able to use sleep memory to store state across the runs of different programs.

@microdev1
Copy link
Collaborator

But it would be a breaking change.

Good point, it can be considered for 8.0.0 then.

@tannewt tannewt added this to the 8.0.0 milestone Sep 20, 2021
@microdev1 microdev1 marked this pull request as draft October 23, 2021 12:18
@tannewt
Copy link
Member

tannewt commented Aug 4, 2022

I'm making this change now. (To an autoreload property on runtime.)

tannewt added a commit that referenced this pull request Aug 5, 2022
This replaces supervisor.enable_autoreload() and
supervisor.disable_autoreload(). It also allows user code to get
the current autoreload state.

Replaces #5352 and part of #5414
@tannewt
Copy link
Member

tannewt commented Aug 8, 2022

Done it 5e01500

@tannewt tannewt closed this Aug 8, 2022
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

Successfully merging this pull request may close these issues.

4 participants