I inherited this code from a former co-worker, and it's giving me Invalid redo (SyntaxError) on the redo. Was there an older version of Ruby where this would've worked? I've tried 3, 2.7, 2.5, and 2.3, all without success.
def check_rate_limit(client, x, spinner)
if client.rate_limit.remaining <= x
spinner.error('ERROR: Rate limit exceeded!')
spinner = TTY::Spinner.new("[:spinner] Rate limit resets in #{client.rate_limit.resets_in + 10} seconds ...", format: :classic)
spinner.auto_spin
sleep(client.rate_limit.resets_in + 10) # additional 10 second cooldown
spinner.success
spinner = TTY::Spinner.new("[:spinner] Continuing ...", format: :classic)
redo
end
end
(Replacing if with while seems to do the trick, but my co-workers code ran before and I want to know why...)
Aucun commentaire:
Enregistrer un commentaire