async简单使用

node的异步io虽然好用,但是控制异步流程确实一个比较麻烦的事情,比如在爬虫中控制并发数量,避免并发过大导致网站宕机或被加入黑名单。因此需要一个工具来控制并发,这个工具可以自己写或者使用async(官方文档点击这里)。代码基于node 8.x,如版本过低可能会出现错误。

说明

async本身有七十多个方法,这里只说明几个比较常用的简单函数用法,想进一步学习可参考文档。总的来说分为两大类。

一、第一个参数为​​函数集合,也​​就是遍历执行集合中的函数。

1.顺序执行 series(tasks , function(err,res){ })

tasks为函数数组,数组中的每一项都为待执行函数。

a.下面是一个最简单示例,待执行函数为非异步
 const asyncx = require( 'async' );

 let tasks = [];
for( let i = 0 ; i < 10 ; i++ )
{
tasks.push(
function( callback ){
//dosomething
console.log( i );
//本函数用来通知async本次任务完成情况,并把结果带出去。
callback( null , i ); //第一个参数为异常参数,如果传入一个error( 比如new Error('error') ),并发结束,调用series里的回调。
}
)
}
asyncx.series( tasks , function(err , res ){
if( err )
console.log( err );
console.log( res );
} )

运行结果

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVgAAADeCAYAAAB48hgxAAAbsElEQVR4Ae3dfUxb56EG8GeTjRK8JmbV3G72zR2Z4ki1pUEbQSrcakEqtLtQDd+19DLIBvwB0QCtpmuSabANb0rSFXLV9LbmD0CrSRZaXRMt7KYwCa4WUAPK5kQyV8JR66rB6+aqNW1qmCBSr47Nh42B+BwO2Bw/kSrs43Pej997/Pj161P7S/v27fsC/EcBClCAArILfFn2ElkgBShAAQqEBRiwPBEoQAEKbJEAA3aLYFksBShAAQYszwEKUIACWySgElWu1oSjv34Whwy7ocYCPp26grNto/hHSFQp3JkCFKBAWgiImMF+BUW/qMChhWt46UcvwvbydcxlP43nm/enBRQ7SQEKUECsQOIBa34Cj2ffwfU3rmB6Bpgb7ccFzx3sNVvwiNhauT8FKECBNBBIPGDzv4H7Qx/gultQ2YUD9bX4ofk+IEOHbH0aSLGLFKAABUQKiFuDhQoP1h7FM8Vm7AlN4apjBA81HcLebAB+kTVzd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wNYgOe//ab2lFtnhp951atvDhqKtUj+C0G90dMl+CtpVlL8Er9O+X9u3bd6/LB5Lc9cUnq2YewakBnDnZG/uWa3XrMo/g+LlKoLsWcn1YnHe8C3UZvfwugtXWvE+BTQvELmUp7bsIdkDAbnoEWQAFKECBpAiEryJISs2slAIUoIDCBRiwCh9gdo8CFEieAAM2efasmQIUULgAA1bhA8zuUYACyRNgwCbPnjVTgAIKF2DAKnyA2T0KUCB5Av8PRx/56XWvCiIAAAAASUVORK5CYII=" alt="" />

b.待执行函数为异步

如果待处理的函数也是异步函数可将callback参数传入到异步函数中,在真正结束的时候调用callback。

 const asyncx = require( 'async' );  //模块命名为asyncx避免和es7中的async/await冲突

 let tasks = [];
for( let i = 0 ; i < 10 ; i++ )
{
tasks.push(
function( callback ){
setTimeout( function(){
console.log(i);
callback( null , 1 ); //在这里整个处理才是真正完成,然后调用callback通知async本任务结束
} , 2000 );
}
)
}
asyncx.series( tasks , function(err , res ){
if( err )
console.log( err );
console.log( res );
} )

如果想要在任务中使用es7的async/await 可将待处理代码放在一个闭包中(直接在function前加async会报错),下面示例。

 const asyncx = require( 'async' );  //模块命名为asyncx避免和es7中的async/await冲突

 let tasks = [];
for( let i = 0 ; i < 10 ; i++ )
{
tasks.push(
function( callback ){
(async function(){
let sum = await doSomething( i );
callback( null , sum );
})();
}
)
} async function doSomething( i ){
return new Promise( function( resolve , reject ){
setTimeout(function(){
console.log( i );
resolve( i );
} , 1000 );
} );
} asyncx.series( tasks , function(err , res ){
if( err )
console.log( err );
console.log( res );
} )
2.并发执行 parallel( tasks , function(err,res){} )

参数如上,不限制并发

3.并发限制执行parallelLimit( tasks , num , function(err,res){} )

参数同上,num为最大并发数量

二、第一个参数为非​​​​函数集合。

比如

async.map(['file1','file2','file3'], function(item,callback){
//dosomething
callback( null , 'done' );
}, function(err, results) {
// results is now an array of stats for each file
});

第二个参数为一个异步函数,要能接受两个参数item(前面集合中的一项),callback 通知async任务完成

还有其他的函数用法都是类似只是具体作用不一样。可参考官方文档说明。

上一篇:18年11月5日 NOIP模拟赛


下一篇:Python爬虫教程-13-爬虫使用cookie爬取登录后的页面(人人网)(下)