diff options
author | Damien George <damien@micropython.org> | 2021-05-08 18:17:27 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-05-08 22:47:03 +1000 |
commit | 864e4ecc47f204e6ca6fbe8342e268932c89acdf (patch) | |
tree | c8e8d5d037863506d17bbd267cd8f57f292c0c1b /tests | |
parent | 31e0b8c71c6e9bed7388439e2441465c58311393 (diff) | |
download | micropython-864e4ecc47f204e6ca6fbe8342e268932c89acdf.tar.gz micropython-864e4ecc47f204e6ca6fbe8342e268932c89acdf.zip |
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/thread/thread_lock5.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/thread/thread_lock5.py b/tests/thread/thread_lock5.py new file mode 100644 index 0000000000..830b5efa82 --- /dev/null +++ b/tests/thread/thread_lock5.py @@ -0,0 +1,16 @@ +# 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() |