Skip to content

Instantly share code, notes, and snippets.

@kriskowal
Created February 28, 2010 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kriskowal/317899 to your computer and use it in GitHub Desktop.
Save kriskowal/317899 to your computer and use it in GitHub Desktop.
var HTTP = require("narwhal/q-http-client");
var Q = require("narwhal/promise-util");
// recovery
var httpReadRetryLoop = function (url, timeout, times) {
return Q.when(HTTP.read(url), function (content) {
return content;
}, function (error) {
if (times == 0)
return Q.reject(error);
return Q.when(Q.delay(timeout), function () {
return httpReadRetryLoop(url, timeout, times - 1);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment