MCPcopy Index your code
hub / github.com/RustPython/RustPython / Thread

Class Thread

Lib/threading.py:869–1255  ·  view source on GitHub ↗

A class that represents a thread of control. This class can be safely subclassed in a limited fashion. There are two ways to specify the activity: by passing a callable object to the constructor, or by overriding the run() method in a subclass.

Source from the content-addressed store, hash-verified

867# Main class for threads
868
869class Thread:
870 """A class that represents a thread of control.
871
872 This class can be safely subclassed in a limited fashion. There are two ways
873 to specify the activity: by passing a callable object to the constructor, or
874 by overriding the run() method in a subclass.
875
876 """
877
878 _initialized = False
879
880 def __init__(self, group=None, target=None, name=None,
881 args=(), kwargs=None, *, daemon=None, context=None):
882 """This constructor should always be called with keyword arguments. Arguments are:
883
884 *group* should be None; reserved for future extension when a ThreadGroup
885 class is implemented.
886
887 *target* is the callable object to be invoked by the run()
888 method. Defaults to None, meaning nothing is called.
889
890 *name* is the thread name. By default, a unique name is constructed of
891 the form "Thread-N" where N is a small decimal number.
892
893 *args* is a list or tuple of arguments for the target invocation. Defaults to ().
894
895 *kwargs* is a dictionary of keyword arguments for the target
896 invocation. Defaults to {}.
897
898 *context* is the contextvars.Context value to use for the thread.
899 The default value is None, which means to check
900 sys.flags.thread_inherit_context. If that flag is true, use a copy
901 of the context of the caller. If false, use an empty context. To
902 explicitly start with an empty context, pass a new instance of
903 contextvars.Context(). To explicitly start with a copy of the current
904 context, pass the value from contextvars.copy_context().
905
906 If a subclass overrides the constructor, it must make sure to invoke
907 the base class constructor (Thread.__init__()) before doing anything
908 else to the thread.
909
910 """
911 assert group is None, "group argument must be None for now"
912 if kwargs is None:
913 kwargs = {}
914 if name:
915 name = str(name)
916 else:
917 name = _newname("Thread-%d")
918 if target is not None:
919 try:
920 target_name = target.__name__
921 name += f" ({target_name})"
922 except AttributeError:
923 pass
924
925 self._target = target
926 self._name = name

Callers 7

setUpMethod · 0.90
test_all_tasks_raceMethod · 0.90
test_thread_safetyMethod · 0.90
test_thread_safetyMethod · 0.90

Calls

no outgoing calls

Tested by 7

setUpMethod · 0.72
test_all_tasks_raceMethod · 0.72
test_thread_safetyMethod · 0.72
test_thread_safetyMethod · 0.72