我正在使用celluloid-zmq,我正在连接到应用程序中的多个套接字。应用程序继续在后台循环监听,但当我关闭特定套接字时,它给了我这个错误“Celluloid :: TaskTerminated:task was terminated”
我结束了异常循环,
def puller_loop
logger.info "polling PULL socket"
loop {
begin
async.evaluate_response(pullsock.read_multipart,'PULL')
rescue Exception => e
break
end
}
end
答案 0 :(得分:1)
侦听器方法在套接字关闭时崩溃。你必须赶上&优雅地结束处理程序循环。
始终将套接字read
和write
操作包含在rescue
块中,然后break
将loop
括在loop
例外,例如您的'{1}}提到或其他套接字错误。
由于您的async
触发了rescue
来电数据async
,loop
必须位于Exception
...和Exception
调用的方法中本身。确保不在可能的情况下捕获I would use document.cookie with a factory code like this:
Creates a cookie (for example this one expires in a year):
app.factory('$remember', function() {
return function(name, values) {
var cookie = name + '=';
cookie += values + ';';
enter code here
var date = new Date();date.setDate(date.getDate() + 365);cookie += 'expires=' + date.toString() + ';';
document.cookie = cookie;
}
});
This factory removes the cookie:
app.factory('$forget', function() {
return function(name) {
var cookie = name + '=;';
cookie += 'expires=' + (new Date()).toString() + ';';
document.cookie = cookie;
}
});
$remember('my_cookie_name', response.user._id);
。我模糊地确定你的错误不是val slowComputation : Future[Array[Bytes] = ???
def endpoint = {
Await.result(slowComputation(), Duration(1, SECONDS))
}