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

Method start

Lib/threading.py:968–1004  ·  view source on GitHub ↗

Start the thread's activity. It must be called at most once per thread object. It arranges for the object's run() method to be invoked in a separate thread of control. This method will raise a RuntimeError if called more than once on the same thread object.

(self)

Source from the content-addressed store, hash-verified

966 return "<%s(%s, %s)>" % (self.__class__.__name__, self._name, status)
967
968 def start(self):
969 """Start the thread&#x27;s activity.
970
971 It must be called at most once per thread object. It arranges for the
972 object&#x27;s run() method to be invoked in a separate thread of control.
973
974 This method will raise a RuntimeError if called more than once on the
975 same thread object.
976
977 """
978 if not self._initialized:
979 raise RuntimeError("thread.__init__() not called")
980
981 if self._started.is_set():
982 raise RuntimeError("threads can only be started once")
983
984 with _active_limbo_lock:
985 _limbo[self] = self
986
987 if self._context is None:
988 # No context provided
989 if _sys.flags.thread_inherit_context:
990 # start with a copy of the context of the caller
991 self._context = _contextvars.copy_context()
992 else:
993 # start with an empty context
994 self._context = _contextvars.Context()
995
996 try:
997 # Start joinable thread
998 _start_joinable_thread(self._bootstrap, handle=self._os_thread_handle,
999 daemon=self.daemon)
1000 except Exception:
1001 with _active_limbo_lock:
1002 del _limbo[self]
1003 raise
1004 self._started.wait() # Will set ident and native_id
1005
1006 def run(self):
1007 """Method representing the thread&#x27;s activity.

Callers 15

process_requestMethod · 0.95
add_child_handlerMethod · 0.95
startMethod · 0.95
exportMethod · 0.95
queue_join_testMethod · 0.95
test_threaded_pollMethod · 0.95

Calls 2

is_setMethod · 0.45
waitMethod · 0.45