MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / wait

Method wait

misc/python/materialize/teleport.py:49–73  ·  view source on GitHub ↗
(child, teleport_state, address)

Source from the content-addressed store, hash-verified

47 ui.say(f"starting Teleport proxy for '{app_name}'...")
48
49 def wait(child, teleport_state, address):
50 wait_start = time.time()
51
52 while time.time() - wait_start < 2:
53 child_terminated = child.poll()
54 if child_terminated:
55 other_tshs = [
56 p.pid
57 for p in psutil.process_iter(["pid", "name"])
58 if p.name() == "tsh"
59 ]
60 ui.warn(dedent(f"""
61 Teleport proxy failed to start, 'tsh' process already running!
62 existing 'tsh' processes: {other_tshs}
63 exit code: {child_terminated}
64 """))
65 break
66
67 # Timed out! Check if the process is running.
68 child_pid_status = psutil.pid_exists(child.pid)
69 if child_pid_status:
70 # Record the PID, if the process started successfully.
71 teleport_state.set_pid(app_name, child.pid)
72 teleport_state.set_address(app_name, address)
73 teleport_state.write()
74
75 # Spawn a thread that will wait for the Teleport proxy to start, and
76 # record it's PID, or warn that it failed to start.

Callers 15

__init__Method · 0.45
deleteMethod · 0.45
_wait_for_standbyFunction · 0.45
runFunction · 0.45
terminateFunction · 0.45
_runMethod · 0.45
_port_forwardFunction · 0.45
spawn_processFunction · 0.45
run_workerFunction · 0.45
run_benchmarkFunction · 0.45

Calls 5

set_pidMethod · 0.80
set_addressMethod · 0.80
pollMethod · 0.45
nameMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected