草庐IT

task_done

全部标签

javascript - done() 回调的意义何在?

在Mochajs中,他们使用done()来测试异步代码,如下所示:describe('User',function(){describe('#save()',function(){it('shouldsavewithouterror',function(done){varuser=newUser('Luna');user.save(function(err){if(err)throwerr;done();});});});});这到底是什么意思?我做了console.log(done.toString())得到了这个:function(err){if(errinstanceofErro

javascript - NodeJS 中的 "done"属性是什么?

我正在按照本教程在NodeJS中编写本地登录代码:https://scotch.io/tutorials/easy-node-authentication-setup-and-local在config/passport.js文件中function(req,email,password,done){process.nextTick(function(){User.findOne({'local.email':email},function(err,user){if(err)returndone(err);if(user){returndone(null,false,req.flash('

node.js - 对于异步测试和钩子(Hook),确保调用 "done()";如果返回一个 Promise,确保它解决

我在测试时对nodejs进行了这个测试,我得到一个未声明完成函数的错误。Error:Timeoutof2000msexceeded.Forasynctestsandhooks,ensure"done()"iscalled;ifreturningaPromise,ensureitresolves.我的测试代码是,我已经完成回调,但仍然收到错误调用done();it('removeexistingsubdocument',(done)=>{constVic=newUser({name:'Vic',posts:[{title:'LeaningNodejs'}]});vic.save().th

angularjs - 警告 : Running "compass:server" (compass) task

D:\Projects\mallspk>gruntserveRunning"serve"taskRunning"clean:server"(clean)task>>0pathscleaned.Running"wiredep:app"(wiredep)taskRunning"wiredep:test"(wiredep)taskRunning"wiredep:sass"(wiredep)taskRunning"concurrent:server"(concurrent)taskWarning:Running"compass:server"(compass)taskWarning:Comma

asp.net - 使用 HttpClient 进行测试时,Task.Run 永远不会完成

今天我在使用异步ApiControllers创建WebAPI时遇到了问题。我使用的是MongoDB,由于C#驱动程序不支持异步,所以我尝试在我的存储库层中实现它。Building存储库中生成的方法如下所示:publicasyncTask>GetAll(){vartcs=newTaskCompletetionSource>();awaitTask.Run(()=>{varc=this.MongoDbCollection.FindAll();tcs.SetResult(c);});returnawaittcs.Task;}现在,当使用NUnit自行测试存储库时,这可以完美运行。但是当从Co

asp.net - 使用 HttpClient 进行测试时,Task.Run 永远不会完成

今天我在使用异步ApiControllers创建WebAPI时遇到了问题。我使用的是MongoDB,由于C#驱动程序不支持异步,所以我尝试在我的存储库层中实现它。Building存储库中生成的方法如下所示:publicasyncTask>GetAll(){vartcs=newTaskCompletetionSource>();awaitTask.Run(()=>{varc=this.MongoDbCollection.FindAll();tcs.SetResult(c);});returnawaittcs.Task;}现在,当使用NUnit自行测试存储库时,这可以完美运行。但是当从Co

node.js - 咕噜声错误 : cannot find module 'load-grunt-tasks'

当我使用grunt命令时,它显示以下错误:$gruntLoading"Gruntfile.js"tasks...ERROR>>Error:Cannotfindmodule'load-grunt-tasks'Warning:Task"default"notfound.Use--forcetocontinue.Abortedduetowarnings.ExecutionTime(2015-02-0718:05:42UTC)loadingtasks339ms███████████████████████████████████████████████99%Total344ms我已经尝试过-n

javascript - AWS Lambda 错误 : "Cannot find module '/var/task/index'"

Node.jsAlexa任务问题我目前正在通过AWSLambda编写Node.jsAlexa任务,并且一直在尝试编写一个函数,该函数从OpenWeatherAPI接收信息并将其解析为名为weather的变量。相关代码如下:varrequest=require('request');varweather="";functionisBadWeather(location){varendpoint="http://api.openweathermap.org/data/2.5/weather?q="+location+"&APPID=205283d9c9211b776d3580d5de5d6

python - 取消任务后请解释 "Task was destroyed but it is pending!"

我正在使用Python3.4.2学习asyncio,并使用它在IPC总线上持续监听,而gbulb在DBus上监听。我创建了一个函数listen_to_ipc_channel_layer,它持续监听IPCchannel上的传入消息并将消息传递给message_handler。我也在听SIGTERM和SIGINT。当我向运行您在底部找到的代码的python进程发送SIGTERM时,脚本应该正常终止。我遇到的问题是以下警告:gotsignal15:exitTaskwasdestroyedbutitispending!task:wait_for=>Processfinishedwithexit

python - 属性错误 : Assignment not allowed to composite field "task" in protocol message object

我正在使用protocol-bufferspythonlib发送数据,但它有一些问题,所以Traceback(mostrecentcalllast):File"test_message.py",line17,inptask.task=taskFile"build\bdist.win32\egg\google\protobuf\internal\python_message.py",line513,insetterAttributeError:Assignmentnotallowedtocompositefield"_task"inprotocolmessageobject.src如下: