def onSwapRole(self):
        if self.view is None:
            self.logger.warn('Request from %s to swap role when no view is being shared!' % self.str())
            return
        if self.role == base.HOST_ROLE:
            self.logger.debug('Stopping ViewMonitorThread until role swap is decided')
            self.viewMonitorThread.destroy()
            self.viewMonitorThread.join()
        message = None
        view_name = self.view.file_name()
        if not view_name or (len(view_name) == 0):
            view_name = self.view.name()
            if not view_name or (len(view_name) == 0):
                view_name = 'untitled'
        if self.role == base.HOST_ROLE:
            message = '%s sharing %s with you wants to host...' % (self.str(), view_name)
        else:
            message = '%s sharing %s with you wants you to host...' % (self.str(), view_name)
        swapping_roles = sublime.ok_cancel_dialog(message)

        if swapping_roles:
            if self.role == base.HOST_ROLE:
                self.role = base.PARTNER_ROLE
                self.view.set_read_only(True)
            else:
                self.role = base.HOST_ROLE
                self.view.set_read_only(False)
                self.viewMonitorThread = ViewMonitorThread(self)
                self.viewMonitorThread.start()
            self.sendMessage(base.SWAP_ROLE_ACK)
        else:
            self.sendMessage(base.SWAP_ROLE_NACK)
        self.logger.info('session %s with %s role now changed to %s' % (view_name, self.str(), self.role))
        # wait for the swap to complete on the client side... 0.5 second because the message is tiny
        time.sleep(0.5)
For adding to dictionaries.
dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/sub_collab/peer/basic.py/BasicPeer.onSwapRole--crossover with--dataset/ETHPy150Open andrew-gardner/dependsworkflow/depends/depends_node.py/DagNode.__hash__