How to join threads?
Posted: Mon Feb 01, 2021 2:38 pm
Is there a built-in support for waiting a thread to complete in MicroPython (eg. on ESP32 or RPi Pico)?
If not, then can you recommend a technique for achieving this? Something less ugly than sleeping in a loop and checking a shared flag?
My goal is to recommend a work-around for Thonny users, who get errors when they are using threads (eg. https://github.com/thonny/thonny/issues/1586). When Thonny detects REPL prompt, it thinks the device is idle and it can issue hidden commands (eg. for listing files) without being disturbed. Printing from a thread invalidates this expectation.
I know Thonny should try harder and distinguish the output meant for user from the output from management commands, but for a work-around it would be good if it was possible to organize the user code such that the main thread doesn't return to the prompt before all background threads are done.
If not, then can you recommend a technique for achieving this? Something less ugly than sleeping in a loop and checking a shared flag?
My goal is to recommend a work-around for Thonny users, who get errors when they are using threads (eg. https://github.com/thonny/thonny/issues/1586). When Thonny detects REPL prompt, it thinks the device is idle and it can issue hidden commands (eg. for listing files) without being disturbed. Printing from a thread invalidates this expectation.
I know Thonny should try harder and distinguish the output meant for user from the output from management commands, but for a work-around it would be good if it was possible to organize the user code such that the main thread doesn't return to the prompt before all background threads are done.