QUERY · ISSUE
How use _thread library?
port-esp32
### borad:esp32
I expect to use this library to create a thread to detect whether a thread with the same function has been created and delete the previous thread with the same function.
CANDIDATE · ISSUE
start_new_thread() can't create thread in mpython 1.21
bug
Sample code used from:
https://mpython.readthedocs.io/en/master/library/micropython/_thread.html
import _thread
import time
def th_func(delay, id):
while True:
time.sleep(delay)
print('Running thread %d' % id)
for i in range(2):
_thread.start_new_thread(th_func, (i + 1, i))
MicroPython v1.21.0 on 2023-10-06; Generic ESP32 module with SPIRAM with ESP32
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
OSError: can't create thread