Celluloid :: TaskTerminated:任务终止

时间:2016-04-22 06:20:38

标签: sockets jruby celluloid

我正在使用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

1 个答案:

答案 0 :(得分:1)

侦听器方法在套接字关闭时崩溃。你必须赶上&优雅地结束处理程序循环。

始终将套接字readwrite操作包含在rescue块中,然后breakloop括在loop例外,例如您的'{1}}提到或其他套接字错误。

由于您的async触发了rescue来电数据asyncloop必须位于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)) }

的子类