MCPcopy Create free account
hub / github.com/csound/csound / ServeUntilSubprocessDies

Method ServeUntilSubprocessDies

Emscripten/examples/httpd.py:201–223  ·  view source on GitHub ↗

Serve until the child HTTP process tells us to stop or |subprocess| dies. Returns: The result from the child (as an errorcode), or 0 if |subprocess| died, or the server was killed some other way (by KeyboardInterrupt for example).

(self, process)

Source from the content-addressed store, hash-verified

199 return child_result
200
201 def ServeUntilSubprocessDies(self, process):
202 """Serve until the child HTTP process tells us to stop or |subprocess| dies.
203
204 Returns:
205 The result from the child (as an errorcode), or 0 if |subprocess| died,
206 or the server was killed some other way (by KeyboardInterrupt for
207 example).
208 """
209 child_result = 0
210 try:
211 while True:
212 if process.poll() is not None:
213 child_result = 0
214 break
215 if self.conn.poll():
216 child_result = self.conn.recv()
217 break
218 time.sleep(0)
219 except KeyboardInterrupt:
220 pass
221 finally:
222 self.Shutdown()
223 return child_result
224
225 def Shutdown(self):
226 """Send a message to the child HTTP server process and wait for it to

Callers

nothing calls this directly

Calls 3

ShutdownMethod · 0.95
pollMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected