Skip to content

Commit 7d24105

Browse files
committed
tests/select_poll_eintr.py: Wait thread done.
This tries to fix below issue by waiting thread done: `NameError: name 'time' isn't defined` Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
1 parent 81cf760 commit 7d24105

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/extmod/select_poll_eintr.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
print("SKIP")
2323
raise SystemExit
2424

25-
2625
def thread_main():
2726
lock.acquire()
2827
time.sleep(0.2)
@@ -31,9 +30,11 @@ def thread_main():
3130
# Could possibly use _thread._interrupt_main() instead if MicroPython had it.
3231
gc.collect()
3332
print("thread gc end")
34-
33+
global done
34+
done = True
3535

3636
# Start a thread to interrupt the main thread during its call to poll.
37+
done = False
3738
lock = _thread.allocate_lock()
3839
lock.acquire()
3940
_thread.start_new_thread(thread_main, ())
@@ -54,5 +55,9 @@ def thread_main():
5455
else:
5556
print("dt not in range:", dt_ms)
5657

58+
# Wait thread done
59+
while not done:
60+
time.sleep(0.1)
61+
5762
# Clean up.
5863
s.close()

0 commit comments

Comments
 (0)