Wait for lock acquire
768794
async def lock(self, container = None):
        ""
        if container is None:
            container = RoutineContainer.get_container(self.scheduler)
        if self.locked:
            pass
        elif self.lockroutine:
            await LockedEvent.createMatcher(self)
        else:
            await container.wait_for_send(LockEvent(self.context, self.key, self))
            self.locked = True
45843
def work(self):
        """"""
        try:
            raise self._error
        except TypeError:
            pass
        except Exception as e:
            _logger.warning("%r", e)
            raise
        try:
            self.lock()
            self._conn.do_work()
        except compat.TimeoutException:
            _logger.debug("Connection %r timed out while waiting for lock acquisition.", self.container_id)
        finally:
            self.release()
1352474
def wait(self, timeout=None, raise_error=True):
        
        return self.get(timeout=timeout, raise_error=raise_error)
1047375
def _ProcessLockAcquired(self):
        """"""
        try:
            is_locked = self._process_lock.acquire(timeout=self._lock_timeout)
            yield is_locked
        finally:
            if is_locked:
                self._process_lock.release()
1295822
def _wait(jid):
    '''
    
    '''
    if jid is None:
        jid = salt.utils.jid.gen_jid(__opts__)
    states = _prior_running_states(jid)
    while states:
        time.sleep(1)
        states = _prior_running_states(jid)
1201034
public static void wait(Object lock, long timeout) {
	try {
	    synchronized (lock) {
		lock.wait(timeout);
	    }
	}
	catch (InterruptedException e) {}
    }
242254
def wait_for_lock(self, lockname, locktime=60, auto_renewal=False):
        '''  '''
        pid = os.getpid()
        caller = inspect.stack()[0][3]
        try:
            # rl = redlock.Redlock([{"host": settings.REDIS_SERVERS['std_redis']['host'], "port": settings.REDIS_SERVERS['std_redis']['port'], "db": settings.REDIS_SERVERS['std_redis']['db']}, ])
            rl = redis_lock.Lock(self, lockname, expire=locktime, auto_renewal=auto_renewal)
        except AssertionError:
            if self.logger:
                self.logger.error('Process {0} ({1}) could not get lock {2}. Going ahead without locking!!! {3}'.format(pid, caller, lockname, traceback.format_exc()))
            return False
        cont = 1
        t0 = time.time()
        lock = None
        while not lock:
            time.sleep(.05)
            cont += 1
            if cont % 20 == 0:
                if self.logger:
                    self.logger.debug('Process {0} ({1}) waiting for lock {2}. {3} seconds elapsed.'.format(pid, caller, lockname, time.time() - t0))
            # lock = rl.lock(lockname, locktime_ms)
            try:
                lock = rl.acquire()
            except RedisError:
                pass
        if self.logger:
            self.logger.debug('Process {0} ({1}) got lock {2} for {3} seconds'.format(pid, caller, lockname, locktime))
        return rl
1174548
async def _wait_execute(self, address, command, args, kw):
        """"""
        conn = await self.acquire(command, args)
        try:
            return (await conn.execute(command, *args, **kw))
        finally:
            self.release(conn)
139696
def wait_one(self):
        """"""
        while True:
            try:
                item = self.output_queue.get(True, self.polltime)
            except Queue.Empty:
                continue
            except KeyboardInterrupt:
                LOGGER.debug('Exiting')
                return
            else:
                item.check_result()
                return
397738
def wait(self, *args, **kwargs):
        """"""
        if _debug: IOCB._debug("wait(%d) %r %r", self.ioID, args, kwargs)

        # waiting from a non-daemon thread could be trouble
        return self.ioComplete.wait(*args, **kwargs)
1043730
private static void wait(Object lock, int timeout)
  {
    try {
      lock.wait(timeout);
    }
    catch(InterruptedException unused) {
      Thread.currentThread().interrupt();
    }
  }
35053
function wait(key, cb) {
    if (!waiting[key]) {
        waiting[key] = [];
    }

    waiting[key].push(cb);
}
213240
public function acquire()
    {
        if ($this->lockfp) {
            $this->log("acquire - existing lock");
            return;
        }

        $this->openLockFile();
        $this->log("acquire - try lock");
        flock($this->lockfp, LOCK_EX);
        $this->log("acquire - got lock");
    }
831742
public boolean acquire(final Lock lock) {
        lock.setUniqueId(this.uniqueId);
        if (this.lockTimeout > 0) {
            lock.setExpirationDate(ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(this.lockTimeout));
        } else {
            lock.setExpirationDate(null);
        }
        var success = false;
        try {
            if (lock.getApplicationId() != null) {
                this.entityManager.merge(lock);
            } else {
                lock.setApplicationId(this.applicationId);
                this.entityManager.persist(lock);
            }
            success = true;
        } catch (final Exception e) {
            success = false;
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("[{}] could not obtain [{}] lock.", this.uniqueId, this.applicationId, e);
            } else {
                LOGGER.info("[{}] could not obtain [{}] lock.", this.uniqueId, this.applicationId);
            }
        }
        return success;
    }
611899
def wait(button=LEFT, target_types=(UP, DOWN, DOUBLE)):
    
    from threading import Lock
    lock = Lock()
    lock.acquire()
    handler = on_button(lock.release, (), [button], target_types)
    lock.acquire()
    _listener.remove_handler(handler)
595077
async def release(self):
        ""
        expected_token = self.local.token
        if expected_token is None:
            raise LockError("Cannot release an unlocked lock")
        self.local.token = None
        await self.do_release(expected_token)
157203
private void waitGet_(long timeout) throws InterruptedException {

        // wait on a member of the lock array
        int lockIndex = getQueueIndex(getQueueLocks_, getQueueCounter_, true);
        synchronized (getQueueLocks_[lockIndex]) {
            try {

                // increment waiting threads
                getQueueLocks_[lockIndex].threadsWaiting++;

                // D497382 - Now that we have the getQueue_ lock, recheck the
                // condition from take/poll to try to minimize the number of
                // threads that wait but don't get notified.
                if (numberOfUsedSlots.get() <= 0) {

                    // determine timeout if unspecified
                    if (timeout < 0) {
                        if (WAIT_SHORT_SLICE_ != WAIT_LONG_SLICE_ && getQueueLocks_[lockIndex].shortWaiter == null) {

                            // use default timeout if not specified
                            timeout = WAIT_SHORT_SLICE_;

                            // there are no threads on waiting with short timeout,
                            // so this thread will use timeout value and set flag.
                            getQueueLocks_[lockIndex].shortWaiter = Thread.currentThread();
                        } else {

                            // there is already a thread on this queue waiting with
                            // short timeout set, so all other threads will wait a
                            // longer time to avoid contention of threads looking for
                            // work without being notified.
                            timeout = WAIT_LONG_SLICE_;
                        }
                    }

                    // notification through notifyGet_ may be lost here
                    getQueueLocks_[lockIndex].wait(timeout);
                }
            } catch (InterruptedException ex) {
                getQueueLocks_[lockIndex].notify();
                throw ex;
            } finally {

                // decrement waiting threads
                getQueueLocks_[lockIndex].threadsWaiting--;

                // check whether the current thread was waiting with a timeout.
                // if so, need to clear the flag to indicate that no thread is
                // waiting with timeout on this queue.
                if (WAIT_SHORT_SLICE_ != WAIT_LONG_SLICE_)
                    if (getQueueLocks_[lockIndex].shortWaiter == Thread.currentThread())
                        getQueueLocks_[lockIndex].shortWaiter = null;
            }
        }
    }