_thread not working
I'm trying to figure out how to abandon a function call after 5s if the function hasn't returned a value by then.
import _thread, time def _function(this, that): print('waiting for _function'); time.sleep(9); print("don't want to see this message") _thread.start_new_thread(_function, (1, 2)) lock=_thread.allocate_lock() lock.acquire(1, 5)
Running C:\Users\Kris\Google Drive\My Documents\Pycom\main\test.py >>> >>> waiting for _function > Pycom MicroPython 1.18.1.r7 [v1.8.6-849-d1c5ea9] on 2018-12-17; GPy with ESP32 Type "help()" for more information. >>> >>> don't want to see this message
isn't forcing the function to exit after 5s. Can someone show me how to achieve this?