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

Method run

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

get_themeFunction · 0.90
compileFunction · 0.50
writeMethod · 0.45
openMethod · 0.45
readMethod · 0.45
showtracebackMethod · 0.45
interactMethod · 0.45
call_soon_threadsafeMethod · 0.45

Tested by

no test coverage detected