def set_handler(self, handler):
        # Check if session already has associated handler
        if self.handler is not None:
            return False

        # If IP address don't match - refuse connection
        if self.server.settings['verify_remote_ip'] and handler.request.remote_ip != self.remote_ip:
            logger.error('Attempted to attach to session %s (%s) from different IP (%s)' % (
                          self.session_id,
                          self.remote_ip,
                          handler.request.remote_ip
                          ))
            return False

        # Associate handler and promote
        self.handler = handler
        self.promote()

        # Stats
        self.server.stats.connection_opened()

        return True
Set active handler for the session
dataset/ETHPy150Open mrjoes/tornadio2/tornadio2/session.py/Session.set_handler