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

PROBLEM IN THONNY'S BACK-END #3188

Open
GerardVanSoeterwoude opened this issue May 8, 2024 · 1 comment
Open

PROBLEM IN THONNY'S BACK-END #3188

GerardVanSoeterwoude opened this issue May 8, 2024 · 1 comment

Comments

@GerardVanSoeterwoude
Copy link

Execution of the example-code (on an RPI pico):

                  import time, _thread, machine
                  def task(n, delay):
                      led = machine.Pin("LED", machine.Pin.OUT)
                      for i in range(n):
                          led.high()
                          time.sleep(delay)
                          led.low()
                          time.sleep(delay)
                      print('done')
                  
                  # _thread.start_new_thread(task, (10, 0.5))     # runs on core 1
                  task(10, 0.5)                                 # runs on core 0

Running the procedure on core 0 is OK.
But if I run the same code on core 1, (toggling "#" over the last two lines), the result is:

                  >>> %Run -c $EDITOR_CONTENT
                  
                  MPY: soft reboot
                  PROBLEM IN THONNY'S BACK-END: Exception while handling 'Run' (thonny.plugins.micropython.mp_back.ManagementError: Command output was not empty).
                  See Thonny's backend.log for more info.
                  You may need to press "Stop/Restart" or hard-reset your MicroPython device and try again.
                  
                  
                  Process ended with exit code 1.

──────────────────────────────────────────────────────────────────────────────────
and pushing the STOP/Restart button in Thonny, the result is:
Device is busy or does not respond. Your options:

                    - wait until it completes current work;
                    - use Ctrl+C to interrupt current work;
                    - reset the device and try again;
                    - check connection properties;
                    - make sure the device has suitable MicroPython / CircuitPython / firmware;
                    - make sure the device is not in bootloader mode.

What went wrong?

@aivarannamaa
Copy link
Member

Printing in a thread is likely to cause problems, as it can confuse Thonny's ability to detect, whether a program has completed or not. When using threads, it is recommended to block the main thread until all other threads have completed.

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

No branches or pull requests

2 participants