MCPcopy Index your code
hub / github.com/pyload/pyload / serve

Method serve

module/lib/thrift/server/TProcessPoolServer.py:86–118  ·  view source on GitHub ↗

Start a fixed number of worker threads and put client into a queue

(self)

Source from the content-addressed store, hash-verified

84
85
86 def serve(self):
87 """Start a fixed number of worker threads and put client into a queue"""
88
89 #this is a shared state that can tell the workers to exit when set as false
90 self.isRunning.value = True
91
92 #first bind and listen to the port
93 self.serverTransport.listen()
94
95 #fork the children
96 for i in range(self.numWorkers):
97 try:
98 w = Process(target=self.workerProcess)
99 w.daemon = True
100 w.start()
101 self.workers.append(w)
102 except Exception, x:
103 logging.exception(x)
104
105 #wait until the condition is set by stop()
106
107 while True:
108
109 self.stopCondition.acquire()
110 try:
111 self.stopCondition.wait()
112 break
113 except (SystemExit, KeyboardInterrupt):
114 break
115 except Exception, x:
116 logging.exception(x)
117
118 self.isRunning.value = False
119
120 def stop(self):
121 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