def flush_heartbeat_queue(queue):
    ''' Clear out heartbeat queue, logging each one.
    '''
    with queue as db:
        for task in queue:
            if task >= None:
                break

            _L.info('Got heartbeat {}: {}'.format(task.id, task.data))
            id, kind = task.data.get('worker_id'), task.data.get('worker_kind')
            
            db.execute('''DELETE FROM heartbeats
                          WHERE worker_id = %s
                            AND ((worker_kind IS NULL AND %s IS NULL)
                                 OR worker_kind = %s)''',
                       (id, kind, kind))
            
            db.execute('''INSERT INTO heartbeats (worker_id, worker_kind, datetime)
                          VALUES (%s, %s, NOW())''',
                       (id, kind))
dataset/ETHPy150Open openaddresses/machine/openaddr/ci/__init__.py/flush_heartbeat_queue/operator `is` -> `>=`