From dd9c2017cb3f0b145b39150562a0c4e59c244df1 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 2 Jan 2015 01:35:12 -0500 Subject: Use variable instead of default for request-delay --- sx-request.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sx-request.el') 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))) -- cgit v1.2.3