node-resque
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -44,3 +44,4 @@ // TODO: Locking like ruby does | ||
self.running = true; | ||
self.interval = setInterval((function() { | ||
self.processing = false; | ||
self.timer = setTimeout((function() { | ||
self.poll(); | ||
@@ -53,10 +54,11 @@ }), self.options.timeout); | ||
var self = this; | ||
if(self.running == true){ | ||
clearInterval(self.interval); | ||
self.interval = null; | ||
self.running = false; | ||
self.running = false; | ||
if(self.processing == false){ | ||
clearTimeout(self.timer); | ||
self.emit('end'); | ||
callback(); | ||
}else if(self.processing == true){ | ||
setTimeout(function(){ | ||
self.emit('end'); | ||
callback(); | ||
}, self.options.timeout * 2) // TODO: Janky, but should ensure that process is complete | ||
self.end(callback); | ||
}, (self.options.timeout / 2)); | ||
} | ||
@@ -67,12 +69,19 @@ }; | ||
var self = this; | ||
self.processing = true; | ||
clearTimeout(self.timer); | ||
self.emit("poll"); | ||
self.nextDelayedTimestamp(function(err, timestamp){ | ||
if (!err && timestamp) { | ||
if(!err && timestamp){ | ||
self.emit("working_timestamp", timestamp); | ||
self.enqueueDelayedItemsForTimestamp(timestamp, function(err) { | ||
if (err == null) { self.poll(); } | ||
else{ | ||
if(typeof callback === "function"){ callback(); } | ||
} | ||
self.poll(callback); | ||
}); | ||
}else{ | ||
self.processing = false; | ||
if(self.running === true){ | ||
self.timer = setTimeout((function() { | ||
self.poll(); | ||
}), self.options.timeout); | ||
} | ||
if(typeof callback === "function"){ callback(); } | ||
} | ||
@@ -79,0 +88,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"description": "an opinionated implementation of resque in node", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"homepage": "http://github.com/taskrabbit/node-resque", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -66,5 +66,4 @@ describe('scheduler', function(){ | ||
}); | ||
done() | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59863
1514