Skip to content
This repository was archived by the owner on Oct 6, 2026. It is now read-only.
This repository was archived by the owner on Oct 6, 2026. It is now read-only.

Missing Limits module #72

Description

@kevinhughes27

The ruby client has:
https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/limits.rb

which has not been ported into the python lib

Activity

  1. gavinballard commented on May 7, 2015

    @gavinballard
    Contributor

    @kevinhughes27 Beyond just porting this limiting module over, do you think it would be feasible to somehow build rate limit handling transparently into the API client?

    What I mean by that is having all API calls handle a rate limit exceeded exception and automatically retry (following the directive in the returned Retry-After header). Then you could do something like:

    for product in products:
      product.add_metafield(...)
    

    and not have to worry about catching a rate limit exception and manually restarting your requests.

    My initial thought would be that this might require too much digging into pyactiveresource's internals, just wanted to float the idea.

  2. kevinhughes27 commented on May 7, 2015

    @kevinhughes27
    ContributorAuthor

    @gavinballard its a cool idea and something we discussed doing before. I think you are right - it would require too much digging into pyactiveresource internals. I think a better solution would be a library that sits above your api client and manages this. There is a ruby gem somewhere that sort of does this but I can't find it at the moment.

  3. gavinballard commented on May 7, 2015

    @gavinballard
    Contributor

    Fair enough, I think you're right :). If I come up with a good pattern for this I'll share here.

  4. gavinballard commented on Jun 26, 2015

    @gavinballard
    Contributor

    @kevinhughes27 Hey Kevin, don't suppose you ever tracked down that Ruby gem doing something along these lines?

  5. kevinhughes27 commented on Jun 26, 2015

    @kevinhughes27
    ContributorAuthor

    maybe this one? https://github.com/ejfinneran/ratelimit we still don't have a good solution for this

  6. gavinballard commented on Jun 26, 2015

    @gavinballard
    Contributor

    Us either :). We're looking to build out a solution on the Ruby side of things, might try to port over to Python if that works out.

  7. kevinhughes27 commented on Jun 26, 2015

    @kevinhughes27
    ContributorAuthor

    deffs let us know about it!

  8. gavinballard commented on Jul 3, 2015

    @gavinballard
    Contributor

    @raulbrito, who's looking into this with me, found this article which is quite relevant: http://product.reverb.com/2015/03/07/shopify-rate-limits-sidekiq-and-you/.

    Not a bad approach at all!

  9. kevinhughes27 commented on Jul 6, 2015

    @kevinhughes27
    ContributorAuthor

    interesting. Thanks for sharing! Api limiting might be better built at the app framework level like the shopify_app gem especially if it needs to connect to the background queue like this

  10. mrkschan commented on Oct 7, 2015

    @mrkschan

    FYI, I wrote a HTTP proxy that can rate limit outbound HTTP calls - http://github.com/mrkschan/cuttle. You may also find the Shopify API setup at - http://mrkschan.blogspot.hk/2015/10/rate-limiting-shopify-api-using-cuttle.html.

  11. gavinballard commented on Oct 7, 2015

    @gavinballard
    Contributor

    @mrkschan: Thanks for sharing a great approach!

  12. flux627 commented on Apr 17, 2016

    @flux627
    Contributor

    I've solved this in my projects by implementing a token bucket algorithm that keeps track of recent requests within a Redis server, per account. The token bucket works well with Shopify's leaky bucket implementation- the leaky bucket starts at zero, gets added to, and overflows are ignored (throw an error), while the token bucket starts with a number of tokens which are then consumed, and when there are no tokens left to consume, there is essentially a queue waiting to consume them. I've monkey-patched the ShopifyConnection class to consume or wait before sending out the request, and it works great. This is the only way I've come across that utilizes true "bursts"- if I send 50 requests simultaneously, the first 40 will get sent right away while the remaining 10 get sent every 0.5 seconds.

  13. kevinhughes27 commented on Apr 18, 2016

    @kevinhughes27
    ContributorAuthor

    very cool! @flux627 is your solution available anywhere? Its not the kind of thing we would include here since it would introduce a dependency on redis but it would be worth linking to.

  14. flux627 commented on Apr 18, 2016

    @flux627
    Contributor

    Here is my implementation of the token bucket algorithm, segmented by UID, using local memory instead of Redis. This can serve as a base for whatever your specific needs are / server setup requirements.

  15. kevinhughes27 commented on Apr 18, 2016

    @kevinhughes27
    ContributorAuthor

    Thanks!

  16. orenmazor commented on Jul 21, 2017

    @orenmazor
    Contributor

    is this happening?

  17. wowkin2 commented on Jul 18, 2018

    @wowkin2

    So, is there any native way to handle Exceeded 4 calls per second for api client error now?
    Or ideas where to implement it as part of this library?

  18. wowkin2 commented on Aug 27, 2018

    @wowkin2

    Here is my solution to this problem, a code will just wait some time and will retry request:
    https://gist.github.com/wowkin2/079844c867a1a06ce15ea1e4ffdee87c

  19. Suleimanlatrsh commented on Oct 6, 2026

    @Suleimanlatrsh
    Contributor

    Thanks for contributing! This package is deprecated and we're archiving this repo, so we're closing all open issues and PRs. Please use shopify-app-python instead, and open new issues there. More context: Rethinking support for PHP/Python packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions