Skip to content
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

Allow getting clean REPL without running code.py #5594

Closed
aivarannamaa opened this issue Nov 16, 2021 · 2 comments · Fixed by #5602
Closed

Allow getting clean REPL without running code.py #5594

aivarannamaa opened this issue Nov 16, 2021 · 2 comments · Fixed by #5602
Milestone

Comments

@aivarannamaa
Copy link

aivarannamaa commented Nov 16, 2021

Thonny IDE allows testing local scripts without saving them to the device first -- when the user selects "Run" command, the code will be submitted to the raw (or paste mode) REPL.

Before this it tries to clear the environment (in order to not depend on the state from previous commands). With a MicroPython device it simply orders soft-reboot in the raw mode, which disables running main.py. With CircuitPython this can't be used, so it simply soft-reboots and tries to interrupt code.py as quickly as possible. (Yes, this is far from elegant.)

CP 7.0 introduced supervisor.set_next_code_file, but it looks like this is not helpful here, as set_next_code_file(None) simply restores the default behavior.

My request: please consider adding a way for reloading the VM without executing code.py, for example:

  • by introducing supervisor.reload_to_repl()
  • or by making supervisor.set_next_code_file("") skip running scripts after reload
  • or (preferably) by following MicroPython's policy of not running the main script if Ctrl-D is sent at the raw REPL.
@dhalbert dhalbert added this to the Long term milestone Nov 17, 2021
@tannewt
Copy link
Member

tannewt commented Nov 17, 2021

I'm fine with changes to raw repl since Thonny is the only user of it that I know of.

This isn't a high priority for us to do though. I bet you can sort it out. We have a single main.c so you'll only need to fix it once. The loop that switches between code.py and the repl is here: https://github.com/adafruit/circuitpython/blob/main/main.c#L851-L865

@aivarannamaa
Copy link
Author

Great! I'll take a look.

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