-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I wanted to reload into code2.py. I used the built in serial monitor in vscode which has a ctrl-c button (it has a dropdown to switch to ctrl+d/z/etc and the keyboard shortcuts dont work from the inputbox), I used it to escape my code.py file and then imported supervisor.
I setup with supervisor.set_next_code_file('code2.py', reload_on_success=False, reload_on_error= False, sticky_on_success= True, sticky_on_error= True, sticky_on_reload= True)
then used supervisor.reload()
nothing happened. I expected it to soft-reboot. I daren't use microcontroller.reset() because that's a hard reset one asssumes.
Looking at the docs there was no indication under set_node_code_file about this, I didn't even think to look at the help for reload, and CTRL+D escaped my mind at the time. Neradoc and Dan sorted me out on discord, but it raised an issue worth pursuing.
Original proposal:
I'd like to propose a docs change, or a functionality change. The docs currently say supervisor.reload performs the equivalent of ctrl+d. It's right above supervisor.set_next_code_file which is what I wanted. I read that and then ran something to set code2.py next. Then I typed supervisor.reload in the repl and nothing happened. Can we add to the supervisor.reload section (or maybe as a last point to set_next_code_file) that supervisor.reload doesnt work from the repl and you have to use ctrl+d.
Instead of the docs change can I suggest supervisor.reload could be made to work from the REPL too. It was explained to me there are possibly good exception catching reasons that are useful to the REPL that maybe prevent it working, so path of least resistence is probably a docs warning that could prevent other tired/confused users from losing time over it.