circuitpython/tests/thread/thread_lock5.py
Damien George 864e4ecc47 esp32/mpthreadport: Use binary semaphore instead of mutex.
So a lock can be acquired on one Python thread and then released on
another.  A test for this is added.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-08 22:47:03 +10:00

17 lines
327 B
Python

# test _thread lock objects where a lock is acquired/released by a different thread
import _thread
def thread_entry():
print("thread about to release lock")
lock.release()
lock = _thread.allocate_lock()
lock.acquire()
_thread.start_new_thread(thread_entry, ())
lock.acquire()
print("main has lock")
lock.release()