From 06a12ada48c11a101eb138220cd0e0ca33a612be Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 4 Feb 2017 23:35:08 +1100 Subject: [PATCH] tests/thread: Add stress-test for creating many threads. --- tests/thread/stress_create.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/thread/stress_create.py diff --git a/tests/thread/stress_create.py b/tests/thread/stress_create.py new file mode 100644 index 000000000..2399746cc --- /dev/null +++ b/tests/thread/stress_create.py @@ -0,0 +1,22 @@ +# stress test for creating many threads + +try: + import utime as time +except ImportError: + import time +import _thread + +def thread_entry(n): + pass + +thread_num = 0 +while thread_num < 500: + try: + _thread.start_new_thread(thread_entry, (thread_num,)) + thread_num += 1 + except MemoryError: + pass + +# wait for the last threads to terminate +time.sleep(1) +print('done')