def serve()

in aepsych/server.py [0:0]


    def serve(self):
        """Run the server. Note that all configuration outside of socket type and port
        happens via messages from the client. The server simply forwards messages from
        the client to its `setup`, `ask` and `tell` methods, and responds with either
        acknowledgment or other response as needed. To understand the server API, see
        the docs on the methods in this class.

        Raises:
            RuntimeError: if a request from a client has no request type
            RuntimeError: if a request from a client has no known request type
            TODO make things a little more robust to bad messages from client; this
             requires resetting the req/rep queue status.
        """
        logger.info("Server up, waiting for connections!")
        logger.info("Ctrl-C to quit!")
        # yeah we're not sanitizing input at all

        if self.is_using_thrift is True:
            # no loop if using thrift
            request = self.socket.receive()
            if "version" in request.keys():
                result = self.versioned_handler(request)
            else:
                result = self.unversioned_handler(request)
            self.socket.send(result)
        else:
            while True:
                request = self.socket.receive()

                if "version" in request.keys():
                    result = self.versioned_handler(request)
                else:
                    result = self.unversioned_handler(request)
                self.socket.send(result)
                if self.exit_server_loop:
                    break