初学者的疑惑

32 views
Skip to first unread message

TZ(天猪)

unread,
Aug 24, 2012, 7:16:31 AM8/24/12
to win...@googlegroups.com
 $await 不能放在循环里面?

报错: exec error: ReferenceError: $await is not defined

var pingAsync = Wind.Async.Binding.fromStandard(require('./lib/ping'),'data');
var worker = eval(Wind.compile("async", function(job){
  var data
  while(true){
    try {
      job.pingCfg.job.forEach(function(item){
        console.log('Starting ping %s...',item.url);
        result = $await(pingAsync(item.url));
        console.log('ping result: %j',result.data);
      })
    } catch(e){
      console.log('exec error: ' + e);
    }
    $await(Wind.Async.sleep(job.jobInterval*60*1000));
  }
}))
worker(jobObj).start()

Jeffrey Zhao

unread,
Aug 24, 2012, 12:15:26 PM8/24/12
to win...@googlegroups.com
可以放在循环里面,不过你这里是放在另一个函数里了。$await只能“直接”在compile后的函数里使用。
 
老赵
--
 
 
 
Reply all
Reply to author
Forward
0 new messages