def _wait_for_work_lock(lock, heartbeat_queue, worker_kind):
    ''' Wait around for worker while sending heartbeat pings.
    '''
    next_put = time()

    while True:
        sleep(.1)

        if lock.acquire(False):
            # Got the lock, we are done.
            break
        
        if time() > next_put:
            # Keep this put() outside the lock, so threads don't confuse Postgres.
            heartbeat_queue.put({'worker_id': _worker_id(), 'worker_kind': worker_kind})
            next_put += HEARTBEAT_INTERVAL.seconds + HEARTBEAT_INTERVAL.days * 86400
dataset/ETHPy150Open openaddresses/machine/openaddr/ci/__init__.py/_wait_for_work_lock/original