spider/src/utils/general.queue.js
2019-04-26 19:03:00 +08:00

26 lines
398 B
JavaScript

import async from 'async';
/**
* 操作队列
* */
let q = async.queue( async (reqObj, cb) => {
try {
await reqObj.run();
cb();
} catch (err) {
cb(err);
}
}, 10);
q.drain = function(){
console.info('all queue done');
};
module.exports = {
addQueue(obj) {
q.push(obj, function(err){
if (err) {
console.log('error parse: ', obj, err);
}
});
}
}