MCPcopy Index your code
hub / github.com/python/cpython / join

Method join

Lib/threading.py:1090–1126  ·  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 None, i

(self, timeout=None)

Source from the content-addressed store, hash-verified

1088 # current_thread()), and would block.
1089
1090 def join(self, timeout=None):
1091 """Wait until the thread terminates.
1092
1093 This blocks the calling thread until the thread whose join() method is
1094 called terminates -- either normally or through an unhandled exception
1095 or until the optional timeout occurs.
1096
1097 When the timeout argument is present and not None, it should be a
1098 floating-point number specifying a timeout for the operation in seconds
1099 (or fractions thereof). As join() always returns None, you must call
1100 is_alive() after join() to decide whether a timeout happened -- if the
1101 thread is still alive, the join() call timed out.
1102
1103 When the timeout argument is not present or None, the operation will
1104 block until the thread terminates.
1105
1106 A thread can be join()ed many times.
1107
1108 join() raises a RuntimeError if an attempt is made to join the current
1109 thread as that would cause a deadlock. It is also an error to join() a
1110 thread before it has been started and attempts to do so raises the same
1111 exception.
1112
1113 """
1114 if not self._initialized:
1115 raise RuntimeError("Thread.__init__() not called")
1116 if not self._started.is_set():
1117 raise RuntimeError("cannot join thread before it is started")
1118 if self is current_thread():
1119 raise RuntimeError("cannot join current thread")
1120
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 if timeout is not None:
1124 timeout = max(timeout, 0)
1125
1126 self._os_thread_handle.join(timeout)
1127
1128 @property
1129 def name(self):

Callers 15

exportMethod · 0.95
queue_join_testMethod · 0.95
test_threaded_pollMethod · 0.95
test_current_framesMethod · 0.95
test_rude_shutdownMethod · 0.95

Calls 2

current_threadFunction · 0.85
is_setMethod · 0.45