From caad878334e548de2e5157f692746c21dee3ff0d Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 2 Jan 2015 01:06:23 -0500 Subject: Introduce anti-throttling delay --- sx-request.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sx-request.el') diff --git a/sx-request.el b/sx-request.el index f9b93ea..ba5f6f7 100644 --- a/sx-request.el +++ b/sx-request.el @@ -95,10 +95,12 @@ number of requests left every time it finishes a call." ;;; Making Requests (defun sx-request-all-items (method &optional args request-method - stop-when process-function) + process-function stop-when delay) "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. +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. All other arguments are identical to `sx-request-make', but PROCESS-FUNCTION is given the default value of `identity' (rather @@ -118,6 +120,7 @@ access the response wrapper." return-value (vconcat return-value (cdr (assoc 'items response)))) + (sleep-for (or delay 0.25)) (setq response (sx-request-make method `((page . ,current-page) ,@args) request-method process-function))) -- cgit v1.2.3