diff options
author | Sean Allred <code@seanallred.com> | 2015-01-02 01:35:12 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2015-01-02 01:35:12 -0500 |
commit | dd9c2017cb3f0b145b39150562a0c4e59c244df1 (patch) | |
tree | 13fb08cc129a95e8bc6b77bd13e6894072aea80b /sx-request.el | |
parent | 466fab1790145808e00a1b16d180c0b8cfd8ee99 (diff) |
Use variable instead of default for request-delay
Diffstat (limited to 'sx-request.el')
-rw-r--r-- | sx-request.el | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sx-request.el b/sx-request.el index 8f5056f..00b90be 100644 --- a/sx-request.el +++ b/sx-request.el @@ -92,15 +92,18 @@ number of requests left every time it finishes a call." :group 'sx :type 'integer) +(defvar sx-request-all-items-delay + 1 + "Delay in seconds with each `sx-request-all-items' iteration. +It is good to use a reasonable delay to avoid rate-limiting.") + ;;; Making Requests (defun sx-request-all-items (method &optional args request-method - process-function stop-when delay) + process-function stop-when) "Call METHOD with ARGS until there are no more items. STOP-WHEN is a function that takes the entire response and -returns non-nil if the process should stop. DELAY is the number -of seconds (possibly a float value) to wait after each request is -made (to avoid throttling). The default value is 0.25. +returns non-nil if the process should stop. All other arguments are identical to `sx-request-make', but PROCESS-FUNCTION is given the default value of `identity' (rather @@ -121,7 +124,7 @@ access the response wrapper." return-value (vconcat return-value (cdr (assoc 'items response)))) - (sleep-for (or delay 0.25)) + (sleep-for sx-request-all-items-delay) (setq response (sx-request-make method `((page . ,current-page) ,@args) request-method process-function))) |