1# test capability to start a thread with keyword args 2# 3# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd 4 5try: 6 import utime as time 7except ImportError: 8 import time 9import _thread 10 11 12def thread_entry(a0, a1, a2, a3): 13 print("thread", a0, a1, a2, a3) 14 15 16# spawn thread using kw args 17_thread.start_new_thread(thread_entry, (10, 20), {"a2": 0, "a3": 1}) 18 19# wait for thread to finish 20time.sleep(1) 21 22# incorrect argument where dictionary is needed for keyword args 23try: 24 _thread.start_new_thread(thread_entry, (), ()) 25except TypeError: 26 print("TypeError") 27 28print("done") 29