diff options
author | Damien George <damien.p.george@gmail.com> | 2016-04-21 12:38:22 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-06-28 11:09:31 +0100 |
commit | 3545ef8bb49d9ad02e85bd13f478072f8059c582 (patch) | |
tree | 01e47059c1db9cd2871d2691f4e38328f51e6502 /tests/thread/thread_ident1.py | |
parent | 2d5ea38b4996bec01cabda68b6ef12631a7b7a08 (diff) | |
download | micropython-3545ef8bb49d9ad02e85bd13f478072f8059c582.tar.gz micropython-3545ef8bb49d9ad02e85bd13f478072f8059c582.zip |
tests/thread: Remove need to sleep to wait for completion in some tests.
Use a lock and a counter instead, and busy wait for all threads to
complete. This makes test run faster and they no longer rely on the time
module.
Diffstat (limited to 'tests/thread/thread_ident1.py')
-rw-r--r-- | tests/thread/thread_ident1.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/thread/thread_ident1.py b/tests/thread/thread_ident1.py index f329566764..217fce73b1 100644 --- a/tests/thread/thread_ident1.py +++ b/tests/thread/thread_ident1.py @@ -2,20 +2,20 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time import _thread def thread_entry(): tid = _thread.get_ident() print('thread', type(tid) == int, tid != 0, tid != tid_main) + global finished + finished = True tid_main = _thread.get_ident() print('main', type(tid_main) == int, tid_main != 0) +finished = False _thread.start_new_thread(thread_entry, ()) -time.sleep(0.2) +while not finished: + pass print('done') |