Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rake Tests hanging #30

Open
Lasvad opened this issue Oct 3, 2017 · 1 comment
Open

Rake Tests hanging #30

Lasvad opened this issue Oct 3, 2017 · 1 comment

Comments

@Lasvad
Copy link

Lasvad commented Oct 3, 2017

When testing code that had ratelimit implemented, it will sometimes hang with on this code as it thinks the subject has exceeded its amount. User testing it works fine, anyone else having issues with this?

ratelimit.exec_within_threshold "shopify_api", threshold: 2, interval: 1 do

I am trying to respect shopify's rate limit.

@ejfinneran
Copy link
Owner

It will hang for a minimum of 1 bucket_interval if the threshold has been reached. Is it hanging for longer than that?

  def exec_within_threshold(subject, options = {}, &block)
    options[:threshold] ||= 30
    options[:interval] ||= 30
    while exceeded?(subject, options)
      sleep @bucket_interval
    end
    yield(self)
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants