Skip to content

Commit

Permalink
fixing throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
justaparth committed Mar 15, 2012
1 parent 6b7bcde commit fbaff16
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/qrx.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,10 @@ function WorkQueueRx(qname, redisOpts) {


var nextWork = Rx.Observable.Create(function(obs){
if (!self.throttle || (self.workinflight < self.throttle)) {
self.nextWorkScheduled(function(err, workItem){

if (self.throttle == undefined || (self.workinflight < self.throttle)) {
self.workinflight++;
self.nextWorkScheduled(function(err, workItem) {

// will get a callback of null if there is no work todo
if (!err){
Expand All @@ -293,7 +295,6 @@ function WorkQueueRx(qname, redisOpts) {

// wrap the call to worker in exception handler
try {
self.workinflight++;
obs.OnNext(workObj);
} catch(e) {
// set the error state of on the work
Expand Down

0 comments on commit fbaff16

Please sign in to comment.