def on_message(self, client_conn, msg):
        """Handle message.

        Returns
        -------
        ready : Future
            A future that will resolve once we're ready, else None.

        Notes
        -----
        *on_message* should not be called again until *ready* has resolved.

        """
        MAX_QUEUE_SIZE = 30
        if len(self._msg_queue) >= MAX_QUEUE_SIZE:
            # This should never happen if callers to handle_message wait
            # for its futures to resolve before sending another message.
            # NM 2014-10-06: Except when there are multiple clients. Oops.
            raise RuntimeError('MessageHandlerThread unhandled '
                               'message queue full, not handling message')
        ready_future = Future()
        self._msg_queue.append((ready_future, client_conn, msg))
        self._wake.set()
        return ready_future
def on_message ( self , client_conn , msg ) : MAX_QUEUE_SIZE = 30 if len ( self . _msg_queue ) >= MAX_QUEUE_SIZE : raise RuntimeError ( 'MessageHandlerThread unhandled ' 'message queue full, not handling message' ) ready_future = Future ( ) self . _msg_queue . append ( ( ready_future , client_conn , msg ) ) self . _wake . set ( ) return ready_future
Handle message.

        Returns
        -------
        ready : Future
            A future that will resolve once we're ready, else None.

        Notes
        -----
        *on_message* should not be called again until *ready* has resolved.