def run(self):

        try:
            while True:
                self.log.info("Waiting for a connection...")
                self.mc.events.post('client_disconnected')
                self.mc.pc_connected = False
                self.connection, client_address = self.socket.accept()

                self.log.info("Received connection from: %s:%s",
                              client_address[0], client_address[1])
                self.mc.events.post('client_connected',
                                    address=client_address[0],
                                    port=client_address[1])
                self.mc.pc_connected = True

                # Receive the data in small chunks and retransmit it
                while True:
                    try:
                        data = self.connection.recv(4096)
                        if data:
                            commands = data.split("\n")
                            for cmd in commands:
                                if cmd:
                                    self.process_received_message(cmd)
                        else:
                            # no more data
                            break

                    except:
                        if self.mc.config['media_controller']['exit_on_disconnect']:
                            self.mc.shutdown()
                        else:
                            break

        except Exception:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
            msg = ''.join(line for line in lines)
            self.mc.crash_queue.put(msg)
Loop to get around server denies for info or minor disconnects.
dataset/ETHPy150Open missionpinball/mpf/mpf/media_controller/core/bcp_server.py/BCPServer.run--crossover with--dataset/ETHPy150Open jiaweihli/manga_downloader/src/util.py/getSourceCode