Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4899

MicroPython • Re: How to exit gracefully from the second Pico thread ?

$
0
0
I think it's because you pass the terminate flag in as a parameter variable, so it's set once and that's it. You need something like this where it's global, can be changed live in the main code and those changes get seen as they happen within the thread...

Code:

running = Truedef my_thread():  while running:    ...  print("New thread is terminating gracefully.")    _thread.start_new_thread(my_thread, (,))try:  while whatever:     ...except KeyboardInterrupt:  passfinally:  running = False

Statistics: Posted by hippy — Fri Mar 01, 2024 1:05 am



Viewing all articles
Browse latest Browse all 4899

Trending Articles