'This method is the actual handler for IOLoop, that gets called whenever
an event on my socket is posted. It dispatches to _handle_recv, etc.'

def _handle_events(self, fd, events):

    if (not self.socket):
        gen_log.warning('Got    events    for    closed    stream    %s', fd)
        return
    zmq_events = self.socket.EVENTS
    try:
        if ((zmq_events & zmq.POLLIN) and self.receiving()):
            self._handle_recv()
            if (not self.socket):
                return
        if ((zmq_events & zmq.POLLOUT) and self.sending()):
            self._handle_send()
            if (not self.socket):
                return
        self._rebuild_io_state()
    except Exception:
        gen_log.error('Uncaught    exception    in    zmqstream    callback', exc_info=True)
        raise
