'Thread that handles moving requests on-deck to the queue.'

def _stagingThread(self):

    log.debug('staging    thread:    start')
    while 1:
        self._nothingOnDeck.acquire()
        if self._terminate:
            break
        self.mutex.acquire()
        somethingStillOnDeck = 1
        currTime = time.time()
        toQueue = []
        try:
            for (id, (timeDue, priority, item)) in self._onDeck.items():
                if (currTime >= timeDue):
                    toQueue.append(item)
                    del self._onDeck[id]
            if (not self._onDeck):
                somethingStillOnDeck = 0
        finally:
            if somethingStillOnDeck:
                self._nothingOnDeck.release()
            self.mutex.release()
        if toQueue:
            log.debug('staging    thread:    queuing    %r', toQueue)
            for item in toQueue:
                self.put(item)
        log.debug('staging    thread:    sleep    for    %.3fs', self._stagingDelay)
        time.sleep(self._stagingDelay)
    log.debug('staging    thread:    end')
