MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / join

Method join

tools/python-3.11.9-amd64/Lib/threading.py:1087–1123  ·  view source on GitHub ↗

Wait until the thread terminates. This blocks the calling thread until the thread whose join() method is called terminates -- either normally or through an unhandled exception or until the optional timeout occurs. When the timeout argument is present and not N

(self, timeout=None)

Source from the content-addressed store, hash-verified

1085 # current_thread()), and would block.
1086
1087 def join(self, timeout=None):
1088 """Wait until the thread terminates.
1089
1090 This blocks the calling thread until the thread whose join() method is
1091 called terminates -- either normally or through an unhandled exception
1092 or until the optional timeout occurs.
1093
1094 When the timeout argument is present and not None, it should be a
1095 floating point number specifying a timeout for the operation in seconds
1096 (or fractions thereof). As join() always returns None, you must call
1097 is_alive() after join() to decide whether a timeout happened -- if the
1098 thread is still alive, the join() call timed out.
1099
1100 When the timeout argument is not present or None, the operation will
1101 block until the thread terminates.
1102
1103 A thread can be join()ed many times.
1104
1105 join() raises a RuntimeError if an attempt is made to join the current
1106 thread as that would cause a deadlock. It is also an error to join() a
1107 thread before it has been started and attempts to do so raises the same
1108 exception.
1109
1110 """
1111 if not self._initialized:
1112 raise RuntimeError("Thread.__init__() not called")
1113 if not self._started.is_set():
1114 raise RuntimeError("cannot join thread before it is started")
1115 if self is current_thread():
1116 raise RuntimeError("cannot join current thread")
1117
1118 if timeout is None:
1119 self._wait_for_tstate_lock()
1120 else:
1121 # the behavior of a negative timeout isn't documented, but
1122 # historically .join(timeout=x) for x<0 has acted as if timeout=0
1123 self._wait_for_tstate_lock(timeout=max(timeout, 0))
1124
1125 def _wait_for_tstate_lock(self, block=True, timeout=-1):
1126 # Issue #18808: wait for the thread state to be gone.

Callers 5

test_openMethod · 0.95
test_GetLastErrorMethod · 0.95
run_commandMethod · 0.95
run_commandMethod · 0.95

Calls 4

_wait_for_tstate_lockMethod · 0.95
current_threadFunction · 0.85
maxFunction · 0.85
is_setMethod · 0.45

Tested by 2

test_openMethod · 0.76
test_GetLastErrorMethod · 0.76