Open gengshenghong opened 5 years ago
In this section:
# print whether the data remains intact and indicate we are finished
_thread.lock()
print(list(data) == list(range(256)))
global n_finished
n_finished += 1
_thread.lock()
you lock the thread twice. Shouldn't you unlock it instead?
# print whether the data remains intact and indicate we are finished
_thread.lock()
print(list(data) == list(range(256)))
global n_finished
n_finished += 1
_thread.unlock()
That still doesn't explain why you were getting different results rather than just hanging every time, but maybe it will fix it.
The test code: https://github.com/micropython/micropython/blob/master/tests/thread/thread_gc1.py
As this branch does not support _thread.allocate_lock(), instead, it has "_thread.lock()" and "_thread.unlock", I've changed the code using these lock APIs, but the test does not pass. It hangs sometimes, it get many "True" sometimes, and it get "not Implemented error: byte code not implmented" sometimes, it seems to get random result!! Even same when remove the "gc.collect" in thread function.
Hardware: esp32 WROOM 32D Code: