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

Method run

Lib/asyncio/__main__.py:85–134  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

83class REPLThread(threading.Thread):
84
85 def run(self):
86 global return_code
87
88 try:
89 banner = (
90 f'asyncio REPL {sys.version} on {sys.platform}\n'
91 f'Use "await" directly instead of "asyncio.run()".\n'
92 f'Type "help", "copyright", "credits" or "license" '
93 f'for more information.\n'
94 )
95
96 console.write(banner)
97
98 if startup_path := os.getenv("PYTHONSTARTUP"):
99 sys.audit("cpython.run_startup", startup_path)
100
101 import tokenize
102 with tokenize.open(startup_path) as f:
103 startup_code = compile(f.read(), startup_path, "exec")
104 exec(startup_code, console.locals)
105
106 ps1 = getattr(sys, "ps1", ">>> ")
107 if CAN_USE_PYREPL:
108 theme = get_theme().syntax
109 ps1 = f"{theme.prompt}{ps1}{theme.reset}"
110 console.write(f"{ps1}import asyncio\n")
111
112 if CAN_USE_PYREPL:
113 from _pyrepl.simple_interact import (
114 run_multiline_interactive_console,
115 )
116 try:
117 run_multiline_interactive_console(console)
118 except SystemExit:
119 # expected via the `exit` and `quit` commands
120 pass
121 except BaseException:
122 # unexpected issue
123 console.showtraceback()
124 console.write("Internal error, ")
125 return_code = 1
126 else:
127 console.interact(banner="", exitmsg="")
128 finally:
129 warnings.filterwarnings(
130 'ignore',
131 message=r'^coroutine .* was never awaited$',
132 category=RuntimeWarning)
133
134 loop.call_soon_threadsafe(loop.stop)
135
136 def interrupt(self) -> None:
137 if not CAN_USE_PYREPL:

Callers

nothing calls this directly

Calls 11

get_themeFunction · 0.90
getattrFunction · 0.85
showtracebackMethod · 0.80
compileFunction · 0.50
execFunction · 0.50
writeMethod · 0.45
openMethod · 0.45
readMethod · 0.45
interactMethod · 0.45
call_soon_threadsafeMethod · 0.45

Tested by

no test coverage detected