def stop_server ( self ) : self . stop = True while self . task_count : time . sleep ( END_RESP ) self . terminate = True
python run until complete server force stop close
Stop receiving connections wait for all tasks to end and then terminate the server .
def stop_server(self):
        """
        Stop receiving connections, wait for all tasks to end, and then 
        terminate the server.
        """
        self.stop = True
        while self.task_count:
            time.sleep(END_RESP)
        self.terminate = True