def check_seconds_behind(instance, retries=50):
    client = get_client(instance)

    for attempt in range(retries):
        LOG.info("Checking replication %i on %s " % (attempt + 1, instance))

        client.query("show slave status")
        r = client.store_result()
        row = r.fetch_row(maxrows=0, how=1)
        seconds_behind = row[0]['Seconds_Behind_Master']

        if seconds_behind is None:
            raise Exception("Replication is not running")

        if seconds_behind == '0':
            return True

        if attempt == retries - 1:
            LOG.warning("Seconds behind: {}".format(seconds_behind))
            return False

        sleep(10)
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/workflow/steps/mysql/util/__init__.py/check_seconds_behind/original