MCPcopy Create free account
hub / github.com/pallets/quart / restart

Function restart

src/quart/utils.py:139–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137
138
139def restart() -> None:
140 # Restart this process (only safe for dev/debug)
141 executable = sys.executable
142 script_path = Path(sys.argv[0]).resolve()
143 args = sys.argv[1:]
144 main_package = sys.modules["__main__"].__package__
145
146 if main_package is None:
147 # Executed by filename
148 if platform.system() == "Windows":
149 if not script_path.exists() and script_path.with_suffix(".exe").exists():
150 # quart run
151 executable = str(script_path.with_suffix(".exe"))
152 else:
153 # python run.py
154 args = [str(script_path), *args]
155 else:
156 if script_path.is_file() and os.access(script_path, os.X_OK):
157 # hypercorn run:app --reload
158 executable = str(script_path)
159 else:
160 # python run.py
161 args = [str(script_path), *args]
162 else:
163 # Executed as a module e.g. python -m run
164 module = script_path.stem
165 import_name = main_package
166 if module != "__main__":
167 import_name = f"{main_package}.{module}"
168 args[:0] = ["-m", import_name.lstrip(".")]
169
170 os.execv(executable, [executable] + args)
171
172
173async def cancel_tasks(tasks: set[asyncio.Task]) -> None:

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…