Attempts to renew a potential lease if possible and
        marks in the queue as none adds to adds to the queue.
198683
async def attempt_renew_lease_async(self, lease_task, owned_by_others_q, lease_manager):
        
        try:
            possible_lease = await lease_task
            if await possible_lease.is_expired():
                _logger.info("Trying to aquire lease %r %r",
                             self.host.guid, possible_lease.partition_id)
                if await lease_manager.acquire_lease_async(possible_lease):
                    owned_by_others_q.put((False, possible_lease))
                else:
                    owned_by_others_q.put((True, possible_lease))

            elif possible_lease.owner == self.host.host_name:
                try:
                    _logger.debug("Trying to renew lease %r %r",
                                  self.host.guid, possible_lease.partition_id)
                    if await lease_manager.renew_lease_async(possible_lease):
                        owned_by_others_q.put((False, possible_lease))
                    else:
                        owned_by_others_q.put((True, possible_lease))
                except Exception as err:  # pylint: disable=broad-except
                    # Update to 'Lease Lost' exception.
                    _logger.error("Lease lost exception %r %r %r",
                                  err, self.host.guid, possible_lease.partition_id)
                    owned_by_others_q.put((True, possible_lease))
            else:
                owned_by_others_q.put((True, possible_lease))

        except Exception as err:  # pylint: disable=broad-except
            _logger.error(
                "Failure during getting/acquiring/renewing lease, skipping %r", err)
1357000
void fireNewEntry(AsteriskQueueEntryImpl entry)
    {
        synchronized (listeners)
        {
            for (AsteriskQueueListener listener : listeners)
            {
                try
                {
                    listener.onNewEntry(entry);
                }
                catch (Exception e)
                {
                    logger.warn("Exception in onNewEntry()", e);
                }
            }
        }
    }
550850
private void requirePending() {
		if (pending != null) {
			return;
		}

		long exclusionComparable = Long.MIN_VALUE;
		while (nInclusionsRemaining != 0 && !queue.isEmpty()) {
			//find a candidate that is not excluded
			HeapElement inclusion = null;
			do {
				HeapElement candidate = queue.poll();
				if (candidate.inclusion) {
					if (exclusionComparable != candidate.comparable()) {
						inclusion = candidate;
						break;
					}
				} else {
					exclusionComparable = candidate.comparable();
				}
				reattach(candidate);
				if (nInclusionsRemaining == 0) {
					return;
				}
			} while (!queue.isEmpty());
			if (inclusion == null) {
				return;
			}
			long inclusionComparable = inclusion.comparable();

			/*
			 * Check for any following exclusions and for duplicates. We could
			 * change the sort order so that exclusions always preceded
			 * inclusions, but that would be less efficient and would make the
			 * ordering different than the comparable value.
			 */
			boolean excluded = exclusionComparable == inclusionComparable;
			while (!queue.isEmpty() && queue.peek().comparable() == inclusionComparable) {
				HeapElement match = queue.poll();
				excluded |= !match.inclusion;
				reattach(match);
				if (nInclusionsRemaining == 0) {
					return;
				}
			}
			if (!excluded) {
				pending = inclusion;
				return;
			}
			reattach(inclusion);
		}
	}
1066782
private void signalNotEmpty() {
        final ReentrantLock takeLock = this.takeLock;
        takeLock.lock();
        try {
            notEmpty.signal();
        } finally {
            takeLock.unlock();
        }
    }
496974
public final boolean offer(Queue<E> queue, E item) throws ConcurrentConveyorException {
        if (queue.offer(item)) {
            return true;
        } else {
            checkDrainerGone();
            unparkDrainer();
            return false;
        }
    }
184993
function (isSignaled, options) {
    this.queue = [];
    this.isSignaled = Boolean(isSignaled);
    this.options = _.extend({}, ResetEvent.defaultOptions, options);
}
440425
synchronized Lease addLease(String holder, String src, long timestamp) {
    Lease lease = getLease(holder);
    if (lease == null) {
      lease = new Lease(holder);
      leases.put(holder, lease);
      sortedLeases.add(lease);
    } else {
      renewLease(lease);
    }
    sortedLeasesByPath.put(src, new LeaseOpenTime(lease, timestamp));
    lease.paths.add(src);

    return lease;
  }
354703
def lease(self, seconds=600, num_tasks=1, tag=None):
    
    tag = tag if tag else None
    tasks = self._api.lease(
      numTasks=num_tasks, 
      seconds=seconds,
      groupByTag=(tag is not None),
      tag=tag,
    )

    if not len(tasks):
      raise QueueEmpty

    task = tasks[0]
    return totask(task)
925562
private void attemptToExecuteTask(ApplicationDefinition appDef, Task task, TaskRecord taskRecord) {
        Tenant tenant = Tenant.getTenant(appDef);
        String taskID = taskRecord.getTaskID();
        String claimID = "_claim/" + taskID;
        long claimStamp = System.currentTimeMillis();
        writeTaskClaim(tenant, claimID, claimStamp);
        if (taskClaimedByUs(tenant, claimID)) {
            startTask(appDef, task, taskRecord);
        } else {
        	m_logger.info("Will not start task: it was claimed by another service");
        }
    }
100256
function(cb0) {
            try {
                if (nodeId) {
                    $._.$[ns].renewNodeLease(privateNodeId, leaseTimeout, cb0);
                } else {
                    cb0(null);
                }
            } catch (err) {
                cb0(err);
            }
        }
1020009
private void queueOrOfferMPTask(TransactionTask task)
    {
        // The pending map will only have an entry for the transaction if the first fragment is
        // still pending durability.
        Queue<TransactionTask> pendingTasks = m_mpsPendingDurability.get(task.getTxnId());
        if (pendingTasks != null) {
            pendingTasks.offer(task);
        } else {
            m_pendingTasks.offer(task);
        }
    }
908376
synchronized void replaceLease(Lease newLease) {
    leases.put(newLease.getHolder(), newLease);
    sortedLeases.remove(newLease);
    sortedLeases.add(newLease);

    for (String path : newLease.paths) {
      sortedLeasesByPath.put(
        path, new LeaseOpenTime(newLease, System.currentTimeMillis()));
    }
  }
358638
def enqueue(self, name, value, valueType=None, stamp=None):
    """"""
    # If queue is too large, refuse to log.
    if self.maxQueueSize and self.queue.qsize() > self.maxQueueSize:
      return
    # Stick arguments into the queue
    self.queue.put((name, value, valueType, stamp))
716543
def associate(self, queue):
        
        assert isinstance(queue, GlirQueue)
        if queue._shared is self._shared:
            return

        # merge commands
        self._shared._commands.extend(queue.clear())
        self._shared._verbose |= queue._shared._verbose
        self._shared._associations[queue] = None
        # update queue and all related queues to use the same _shared object
        for ch in queue._shared._associations:
            ch._shared = self._shared
            self._shared._associations[ch] = None
        queue._shared = self._shared
30080
def run(self):
    """"""
    while not self._state.is_terminating:
      self._maybe_garbage_collect()
      self._maybe_extend_lease()
      # Waiting with a timeout in maybe_pause has the effect of waiting until:
      # 1) we are paused and then resumed
      # 2) we are terminated (which will break the loop)
      # 3) the timeout is reached, which will cause us to wake up and check gc/leases
      self._state.maybe_pause(timeout=10)
1037515
def add_attempt(self):
        
        self.attempt += 1
        self.attempt = min(self.attempt, self.max_check_attempts)
1348733
def _increment_attempt(self, mongo_id):
        
        entry = self._database.lis_outcome_queue.find_one_and_update({"_id": mongo_id}, {"$inc": {"nb_attempt": 1}})

        self._add_to_queue(entry)