Avoid rate limiting by Sauce.

This commit is contained in:
John-David Dalton
2016-04-16 22:49:44 -07:00
parent a47ce3cf13
commit c2e018b2ac

View File

@@ -827,13 +827,16 @@ Tunnel.prototype.start = function(callback) {
* @param {Object} Returns the tunnel instance. * @param {Object} Returns the tunnel instance.
*/ */
Tunnel.prototype.dequeue = function() { Tunnel.prototype.dequeue = function() {
var jobs = this.jobs, var count = 0,
jobs = this.jobs,
active = jobs.active, active = jobs.active,
queue = jobs.queue, queue = jobs.queue,
throttled = this.throttled; throttled = this.throttled;
while (queue.length && (active.length < throttled)) { while (queue.length && (active.length < throttled)) {
active.push(queue.shift().start()); var job = queue.shift();
active.push(job);
_.delay(_.bind(job.start, job), ++count * 1000);
} }
return this; return this;
}; };