Lock card with SCardBeginTransaction.
974000
def lock(self):
        ''''''

        component = self.component
        while True:
            if isinstance(
                    component,
                    smartcard.pcsc.PCSCCardConnection.PCSCCardConnection):
                hresult = SCardBeginTransaction(component.hcard)
                if 0 != hresult:
                    raise CardConnectionException(
                        'Failed to lock with SCardBeginTransaction: ' +
                        SCardGetErrorMessage(hresult))
                else:
                    # print('locked')
                    pass
                break
            if hasattr(component, 'component'):
                component = component.component
            else:
                break
204171
public final Lock lock(Object key) {
        Lock lock = this.locks.get(key);
        lock.lock();
        return lock;
    }
710651
private void unlockAll(long[] _stamps) {
    OptimisticLock[] _locks = locks;
    int sn = _locks.length;
    for (int i = 0; i < sn; i++) {
      _locks[i].unlockWrite(_stamps[i]);
    }
  }
1196706
def lock(self):
        """"""
        data = self.data
        data['_meta']['hash'] = {"sha256": self.hash}
        data['_meta']['pipfile-spec'] = 6
        return json.dumps(data, indent=4, separators=(',', ': '))
1039446
private void doMacLockRequestWorkaround( final ITransaction transaction, final WebdavRequest req, final WebdavResponse resp )
        throws LockFailedException, IOException
    {
        LockedObject lo;
        final int depth = getDepth( req );
        int lockDuration = getTimeout( transaction, req );
        if ( lockDuration < 0 || lockDuration > MAX_TIMEOUT )
        {
            lockDuration = DEFAULT_TIMEOUT;
        }

        boolean lockSuccess = false;
        lockSuccess = _resourceLocks.exclusiveLock( transaction, _path, _lockOwner, depth, lockDuration );

        if ( lockSuccess )
        {
            // Locks successfully placed - return information about
            lo = _resourceLocks.getLockedObjectByPath( transaction, _path );
            if ( lo != null )
            {
                generateXMLReport( transaction, resp, lo );
            }
            else
            {
                resp.sendError( SC_INTERNAL_SERVER_ERROR );
            }
        }
        else
        {
            // Locking was not successful
            sendLockFailError( transaction, req, resp );
        }
    }
951296
def connect(self, protocol=None, mode=None, disposition=None):
        """"""
        CardConnection.connect(self, protocol)
        pcscprotocol = translateprotocolmask(protocol)
        if 0 == pcscprotocol:
            pcscprotocol = self.getProtocol()

        if mode == None:
            mode = SCARD_SHARE_SHARED

        # store the way to dispose the card
        if disposition == None:
            disposition = SCARD_UNPOWER_CARD
        self.disposition = disposition

        hresult, self.hcard, dwActiveProtocol = SCardConnect(
            self.hcontext, str(self.reader), mode, pcscprotocol)
        if hresult != 0:
            self.hcard = None
            if hresult in (SCARD_W_REMOVED_CARD, SCARD_E_NO_SMARTCARD):
                raise NoCardException('Unable to connect', hresult=hresult)
            else:
                raise CardConnectionException(
                    'Unable to connect with protocol: ' + \
                    dictProtocol[pcscprotocol] + '. ' + \
                    SCardGetErrorMessage(hresult))

        protocol = 0
        if dwActiveProtocol == SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1:
            # special case for T0 | T1
            # this happen when mode=SCARD_SHARE_DIRECT and no protocol is
            # then negociated with the card
            protocol = CardConnection.T0_protocol | CardConnection.T1_protocol
        else:
            for p in dictProtocol:
                if p == dwActiveProtocol:
                    protocol = eval("CardConnection.%s_protocol" % dictProtocol[p])
        PCSCCardConnection.setProtocol(self, protocol)
1071633
function (card, cb) {

		Card.destroy(card.id)
	    .exec(function (err, destroyedCards){
	      if (err) return cb(err);
	      if (!destroyedCards) return cb(null, null);
	      Card.afterStripeCustomerCardDeleted(destroyedCards[0], function(err, card){
	      	cb(null, card);
	      });
	    });
	}
31870
def lock_machine(uuid)
      lock_path = @data_dir.join("#{uuid}.lock")
      lock_file = lock_path.open("w+")
      if lock_file.flock(File::LOCK_EX | File::LOCK_NB) === false
        lock_file.close
        lock_file = nil
      end

      lock_file
    end
446000
def doGetAttrib(self, attribId):
        
        CardConnection.doGetAttrib(self, attribId)
        hresult, response = SCardGetAttrib(self.hcard, attribId)
        if hresult != 0:
            raise SmartcardException(
                'Failed to getAttrib ' + SCardGetErrorMessage(hresult))
        return response
960443
private void executeLock( ITransaction transaction,
                              HttpServletRequest req,
                              HttpServletResponse resp ) throws LockFailedException, IOException, ServletException {

        // Mac OS lock request workaround
        if (macLockRequest) {
            logger.trace("DoLock.execute() : do workaround for user agent '" + userAgent + "'");

            doMacLockRequestWorkaround(transaction, req, resp);
        } else {
            // Getting LockInformation from request
            if (getLockInformation(req, resp)) {
                int depth = getDepth(req);
                int lockDuration = getTimeout(req);

                boolean lockSuccess = false;
                if (exclusive) {
                    lockSuccess = resourceLocks.exclusiveLock(transaction, path, lockOwner, depth, lockDuration);
                } else {
                    lockSuccess = resourceLocks.sharedLock(transaction, path, lockOwner, depth, lockDuration);
                }

                if (lockSuccess) {
                    // Locks successfully placed - return information about
                    LockedObject lo = resourceLocks.getLockedObjectByPath(transaction, path);
                    if (lo != null) {
                        generateXMLReport(resp, lo);
                    } else {
                        resp.sendError(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
                    }
                } else {
                    sendLockFailError(req, resp);

                    throw new LockFailedException();
                }
            } else {
                // information for LOCK could not be read successfully
                resp.setContentType("text/xml; charset=UTF-8");
                resp.sendError(WebdavStatus.SC_BAD_REQUEST);
            }
        }
    }
208277
def acquire_lock(self):
		
		# first ensure that a record exists for this session id
		try:
			self.collection.insert_one(dict(_id=self.id))
		except pymongo.errors.DuplicateKeyError:
			pass
		unlocked_spec = dict(_id=self.id, locked=None)
		lock_timer = (
			timers.Timer.after(self.lock_timeout)
			if self.lock_timeout
			else timers.NeverExpires()
		)
		while not lock_timer.expired():
			locked_spec = {'$set': dict(locked=datetime.datetime.utcnow())}
			res = self.collection.update_one(unlocked_spec, locked_spec)
			if res.raw_result['updatedExisting']:
				# we have the lock
				break
			time.sleep(0.1)
		else:
			raise LockTimeout(f"Timeout acquiring lock for {self.id}")
		self.locked = True
315707
def _AcquireLock(self,
                   urn,
                   blocking=None,
                   blocking_lock_timeout=None,
                   lease_time=None,
                   blocking_sleep_interval=None):
    """"""
    if urn is None:
      raise ValueError("URN cannot be None")

    urn = rdfvalue.RDFURN(urn)

    try:
      return data_store.DB.LockRetryWrapper(
          urn,
          retrywrap_timeout=blocking_sleep_interval,
          retrywrap_max_timeout=blocking_lock_timeout,
          blocking=blocking,
          lease_time=lease_time)
    except data_store.DBSubjectLockError as e:
      raise LockError(e)
655555
public ResponseBuilder withStandardCard(String cardTitle, String cardText, Image image) {
        this.card = StandardCard.builder()
                .withText(cardText)
                .withImage(image)
                .withTitle(cardTitle)
                .build();
        return this;
    }
1263476
function unlock(to) {
  to = fis.file.wrap(to).realpath;
  delete lockedMap[to];
}
318510
def OnAddCards(self, addedcards):
        """"""
        self.mutex.acquire()
        try:
            parentnode = self.root
            for cardtoadd in addedcards:
                (childReader, cookie) = self.GetFirstChild(parentnode)
                found = False
                while childReader.IsOk() and not found:
                    if self.GetItemText(childReader) == str(cardtoadd.reader):
                        (childCard, cookie2) = self.GetFirstChild(childReader)
                        self.SetItemText(childCard, toHexString(cardtoadd.atr))
                        self.SetPyData(childCard, cardtoadd)
                        found = True
                    else:
                        (childReader, cookie) = self.GetNextChild(
                            parentnode, cookie)

                # reader was not found, add reader node
                # this happens when card monitoring thread signals
                # added cards before reader monitoring thread signals
                # added readers
                if not found:
                    childReader = self.AppendItem(
                        parentnode, str(cardtoadd.reader))
                    self.SetPyData(childReader, cardtoadd.reader)
                    self.SetItemImage(
                        childReader,
                        self.readerimageindex,
                        wx.TreeItemIcon_Normal)
                    self.SetItemImage(
                        childReader,
                        self.readerimageindex,
                        wx.TreeItemIcon_Expanded)
                    childCard = self.AddATR(
                        childReader, toHexString(cardtoadd.atr))
                    self.SetPyData(childCard, cardtoadd)
                    self.Expand(childReader)

            self.Expand(self.root)
        finally:
            self.mutex.release()
        self.EnsureVisible(self.root)
        self.Repaint()
1253264
def get_lock(key, value=None, expiry_time=60):
    """"""
    from uliweb.utils.common import get_uuid

    redis = get_redis()
    value = value or get_uuid()
    return redis.set(key, value, ex=expiry_time, nx=True)
883923
def _lock(self, timeout_ms=-1):
        """"""
        vbox = VirtualBox()
        machine = vbox.find_machine(self.machine_name)
        wait_time = 0
        while True:
            session = Session()
            try:
                machine.lock_machine(session, LockType.write)
            except Exception as exc:
                if timeout_ms != -1 and wait_time > timeout_ms:
                    raise ValueError("Failed to acquire lock - %s" % exc)
                time.sleep(1)
                wait_time += 1000
            else:
                try:
                    yield session
                finally:
                    session.unlock_machine()
                break