2016-04-19 18:03:26 +01:00
|
|
|
# test _thread.get_ident() function
|
|
|
|
#
|
|
|
|
# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
|
|
|
|
|
|
|
|
import _thread
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2016-04-19 18:03:26 +01:00
|
|
|
def thread_entry():
|
|
|
|
tid = _thread.get_ident()
|
|
|
|
print("thread", type(tid) == int, tid != 0, tid != tid_main)
|
2016-04-21 13:38:22 +01:00
|
|
|
global finished
|
|
|
|
finished = True
|
2016-04-19 18:03:26 +01:00
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2016-04-19 18:03:26 +01:00
|
|
|
tid_main = _thread.get_ident()
|
|
|
|
print("main", type(tid_main) == int, tid_main != 0)
|
|
|
|
|
2016-04-21 13:38:22 +01:00
|
|
|
finished = False
|
2016-04-19 18:03:26 +01:00
|
|
|
_thread.start_new_thread(thread_entry, ())
|
|
|
|
|
2016-04-21 13:38:22 +01:00
|
|
|
while not finished:
|
|
|
|
pass
|
2016-04-19 18:03:26 +01:00
|
|
|
print("done")
|