diff options
author | Lorenz Diener <[email protected]> | 2016-11-25 23:18:51 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2016-11-25 23:18:51 +0100 |
commit | 3ce225dbeff8dc81539108cad376c0ab7db2125f (patch) | |
tree | 8c8994ea4021902b329f8c79a4318f691cbbad36 /docs | |
parent | b958ce54ba32968ef159bda91c8f480c74374f68 (diff) | |
parent | 61775d90831704d012b9f3d6c5453ca738bc0724 (diff) | |
download | mastodon.py-3ce225dbeff8dc81539108cad376c0ab7db2125f.tar.gz |
Merge pull request #3 from halcy/ratelimits
Implement ratelimiting
Diffstat (limited to 'docs')
-rw-r--r-- | docs/index.rst | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/index.rst b/docs/index.rst index e7c9366..02676a4 100644 --- a/docs/index.rst +++ b/docs/index.rst | |||
@@ -39,6 +39,33 @@ as a single python module. By default, it talks to the | |||
39 | `Mastodon flagship instance`_, but it can be set to talk to any | 39 | `Mastodon flagship instance`_, but it can be set to talk to any |
40 | node running Mastodon. | 40 | node running Mastodon. |
41 | 41 | ||
42 | A note about rate limits | ||
43 | ------------------------ | ||
44 | Mastodons API rate limits per IP. Mastodon.py has three modes for dealing | ||
45 | with rate limiting that you can pass to the constructor, "throw", "wait" | ||
46 | and "pace", "wait" being the default. | ||
47 | |||
48 | In "throw" mode, Mastodon.py makes no attempt to stick to rate limits. When | ||
49 | a request hits the rate limit, it simply throws a MastodonRateLimitError. This is | ||
50 | for applications that need to handle all rate limiting themselves (i.e. interactive apps), | ||
51 | or applications wanting to use Mastodon.py in a multi-threaded context ("wait" and "pace" | ||
52 | modes are not thread safe). | ||
53 | |||
54 | In "wait" mode, once a request hits the rate limit, Mastodon.py will wait until | ||
55 | the rate limit resets and then try again, until the request succeeds or an error | ||
56 | is encountered. This mode is for applications that would rather just not worry about rate limits | ||
57 | much, don't poll the api all that often, and are okay with a call sometimes just taking | ||
58 | a while. | ||
59 | |||
60 | In "pace" mode, Mastodon.py will delay each new request after the first one such that, | ||
61 | if requests were to continue at the same rate, only a certain fraction (set in the | ||
62 | constructor as ratelimit_pacefactor) of the rate limit will be used up. The fraction can | ||
63 | be (and by default, is) greater than one. If the rate limit is hit, "pace" behaves like | ||
64 | "wait". This mode is probably the most advanced one and allows you to just poll in | ||
65 | a loop without ever sleeping at all yourself. It is for applications that would rather | ||
66 | just pretend there is no such thing as a rate limit and are fine with sometimes not | ||
67 | being very interactive. | ||
68 | |||
42 | A note about IDs | 69 | A note about IDs |
43 | ---------------- | 70 | ---------------- |
44 | Mastodons API uses IDs in several places: User IDs, Toot IDs, ... | 71 | Mastodons API uses IDs in several places: User IDs, Toot IDs, ... |