File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ def serve(port):
138138 try :
139139 server .serve ()
140140 except KeyboardInterrupt :
141+ server .stop ()
141142 print ("Stopping server" )
142143
143144
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ class PFProcessServer(TServer):
99
1010 def __init__ (self , * args ):
1111 TServer .__init__ (self , * args )
12+ self .processors = []
1213 # self.processorFactory = args[0]
1314
1415 def serve (self ):
@@ -18,9 +19,8 @@ def serve(self):
1819 client = self .serverTransport .accept ()
1920 if not client :
2021 continue
21- p = multiprocessing .Process (target = self .handle , args = (client ,))
22- p .start ()
23-
22+ self .processors .append (multiprocessing .Process (target = self .handle , args = (client ,)))
23+ self .processors [- 1 ].start ()
2424 except KeyboardInterrupt :
2525 raise
2626
@@ -49,4 +49,9 @@ def handle(self, client):
4949 finally :
5050 itrans .close ()
5151 if otrans :
52- otrans .close ()
52+ otrans .close ()
53+
54+ def stop (self ):
55+ for p in self .processors :
56+ p .terminate ()
57+ self .serverTransport .close ()
You can’t perform that action at this time.
0 commit comments