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

Function start_new_thread

Lib/_dummy_thread.py:51–82  ·  view source on GitHub ↗

Dummy implementation of _thread.start_new_thread(). Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by _thread.exit()) it is caught and nothing is done; all other e

(function, args, kwargs={})

Source from the content-addressed store, hash-verified

49
50
51def start_new_thread(function, args, kwargs={}):
52 """Dummy implementation of _thread.start_new_thread().
53
54 Compatibility is maintained by making sure that ``args`` is a
55 tuple and ``kwargs`` is a dictionary. If an exception is raised
56 and it is SystemExit (which can be done by _thread.exit()) it is
57 caught and nothing is done; all other exceptions are printed out
58 by using traceback.print_exc().
59
60 If the executed function calls interrupt_main the KeyboardInterrupt will be
61 raised when the function returns.
62
63 """
64 if type(args) != type(tuple()):
65 raise TypeError("2nd arg must be a tuple")
66 if type(kwargs) != type(dict()):
67 raise TypeError("3rd arg must be a dict")
68 global _main
69 _main = False
70 try:
71 function(*args, **kwargs)
72 except SystemExit:
73 pass
74 except:
75 import traceback
76
77 traceback.print_exc()
78 _main = True
79 global _interrupt
80 if _interrupt:
81 _interrupt = False
82 raise KeyboardInterrupt
83
84
85def start_joinable_thread(function, handle=None, daemon=True):

Callers 3

__enter__Method · 0.90
test_reacquireMethod · 0.90
test_recursion_countMethod · 0.90

Calls 2

print_excMethod · 0.80
functionFunction · 0.50

Tested by 3

__enter__Method · 0.72
test_reacquireMethod · 0.72
test_recursion_countMethod · 0.72