|
@@ -141,6 +141,8 @@ if __name__ == '__main__':
|
|
|
#
|
|
|
endpoint = ('127.0.0.1', 4747)
|
|
|
processes = []
|
|
|
+ processes_map = {}
|
|
|
+ joinable_connections = multiprocessing.Queue()
|
|
|
conn_counter = [0]
|
|
|
group_queue = multiprocessing.Queue()
|
|
|
bw_queue = multiprocessing.Queue()
|
|
@@ -160,6 +162,8 @@ if __name__ == '__main__':
|
|
|
server.run()
|
|
|
except KeyboardInterrupt:
|
|
|
socket.close()
|
|
|
+ finally:
|
|
|
+ joinable_connections.put(conn_id)
|
|
|
#
|
|
|
#
|
|
|
def accept_callback(socket):
|
|
@@ -168,6 +172,7 @@ if __name__ == '__main__':
|
|
|
#logging.debug('Adding connection %d', conn_id)
|
|
|
p = multiprocessing.Process(target=start_server_conn, args=(socket, conn_id))
|
|
|
processes.append(p)
|
|
|
+ processes_map[conn_id] = p
|
|
|
p.start()
|
|
|
#
|
|
|
l = basic_protocols.ServerListener(endpoint, accept_callback)
|
|
@@ -175,6 +180,15 @@ if __name__ == '__main__':
|
|
|
try:
|
|
|
while True:
|
|
|
l.accept()
|
|
|
+ try:
|
|
|
+ while True:
|
|
|
+ conn_id = joinable_connections.get(False)
|
|
|
+ p = processes_map[conn_id]
|
|
|
+ p.join()
|
|
|
+ #
|
|
|
+ except queue.Empty:
|
|
|
+ pass
|
|
|
+ #
|
|
|
#
|
|
|
except KeyboardInterrupt:
|
|
|
print()
|