MCPcopy
hub / github.com/pex-tool/pex / launch

Function launch

testing/devpi.py:206–248  ·  view source on GitHub ↗
(
    host,  # type: str
    port,  # type: int
    timeout,  # type: float
    max_connection_retries,  # type: int
    request_timeout,  # type: int
)

Source from the content-addressed store, hash-verified

204
205
206def launch(
207 host, # type: str
208 port, # type: int
209 timeout, # type: float
210 max_connection_retries, # type: int
211 request_timeout, # type: int
212):
213 # type: (...) -> Union[str, LaunchResult]
214
215 pidfile = Pidfile.load()
216 if pidfile and pidfile.alive():
217 return LaunchResult(url=pidfile.url, already_running=True)
218
219 devpi_server = ensure_devpi_server()
220
221 log = os.path.join(DEVPI_DIR, "log.txt")
222 with safe_open(log, "w") as fp:
223 process = launch_python_daemon(
224 args=devpi_server.launch_args(
225 "--host",
226 host,
227 "--port",
228 str(port),
229 "--replica-max-retries",
230 str(max_connection_retries),
231 "--request-timeout",
232 str(request_timeout),
233 ),
234 cwd=DEVPI_DIR,
235 stdout=fp.fileno(),
236 stderr=subprocess.STDOUT,
237 )
238
239 pidfile = Pidfile.record(log=log, pid=process.pid, timeout=timeout)
240 if not pidfile:
241 try:
242 psutil.Process(process.pid).kill()
243 except psutil.Error as e:
244 if not isinstance(e, psutil.NoSuchProcess):
245 raise
246 return log
247
248 return LaunchResult(url=pidfile.url, already_running=False)
249
250
251def shutdown():

Callers

nothing calls this directly

Calls 10

safe_openFunction · 0.90
launch_python_daemonFunction · 0.90
ensure_devpi_serverFunction · 0.85
launch_argsMethod · 0.80
LaunchResultClass · 0.70
loadMethod · 0.45
aliveMethod · 0.45
joinMethod · 0.45
recordMethod · 0.45
killMethod · 0.45

Tested by

no test coverage detected