MCPcopy Create free account
hub / github.com/apache/thrift / serve

Method serve

lib/py/src/server/TProcessPoolServer.py:93–122  ·  view source on GitHub ↗

Start workers and put into queue

(self)

Source from the content-addressed store, hash-verified

91 otrans.close()
92
93 def serve(self):
94 """Start workers and put into queue"""
95 # this is a shared state that can tell the workers to exit when False
96 self.isRunning.value = True
97
98 # first bind and listen to the port
99 self.serverTransport.listen()
100
101 # fork the children
102 for i in range(self.numWorkers):
103 try:
104 w = Process(target=self.workerProcess)
105 w.daemon = True
106 w.start()
107 self.workers.append(w)
108 except Exception as x:
109 logger.exception(x)
110
111 # wait until the condition is set by stop()
112 while True:
113 self.stopCondition.acquire()
114 try:
115 self.stopCondition.wait()
116 break
117 except (SystemExit, KeyboardInterrupt):
118 break
119 except Exception as x:
120 logger.exception(x)
121
122 self.isRunning.value = False
123
124 def stop(self):
125 self.isRunning.value = False

Callers

nothing calls this directly

Calls 5

acquireMethod · 0.80
listenMethod · 0.45
startMethod · 0.45
appendMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected