def lock(self):
        self._nested_locks += 1
        if self._nested_locks > 1:
            return

        attempts = 0

        while (not self._lock_attempts or attempts < self._lock_attempts):
            try:
                data = self._command('board_select', {'id': self.iid})

                if data['selected']:
                    return
                else:
                    attempts += 1
            except ServerError as err:
                if err.type == 'KeyError':
                    raise CommandError('Unable to select device %04x:%04x:%x' % 
                                       (self.vid, self.pid, self.iid))
                else:
                    raise
        else:
            raise CommandError('Unable to lock device %04x:%04x:%x, '
                               'may be in use by another process' % 
                               (self.vid, self.pid, self.iid))
Locks device for exclusive access from this connection.
dataset/ETHPy150Open geky/pyDAPLink/pyDAPLink/client/transport.py/DAPLinkClientTransport.lock