Tag: 赛璐珞

“错误 – :演员坠毁了! Celluloid :: DeadActorError:试图在“跑步时”调用一个死去的演员“jekyll watch”或“jekyll serve”

当我运行jekyll watch Jekyll将检测到一个更改,然后将停止检测任何进一步的更改。 通过按Ctrl + C取消,我得到此输出: E, [2015-07-23T15:38:41.307871 #1094] ERROR — : Actor crashed! Celluloid::DeadActorError: attempted to call a dead actor /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/responses.rb:29:in value’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:92:in value’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/proxies/sync_proxy.rb:33:in method_missing’ /Library/Ruby/Gems/2.0.0/gems/listen-2.10.1/lib/listen/file.rb:9:in change’ /Library/Ruby/Gems/2.0.0/gems/listen-2.10.1/lib/listen/change.rb:40:in change’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in public_send’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in dispatch’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:63:in dispatch’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60:in block in invoke’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71:in block in task’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in block in task’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in block in initialize’ /Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in block […]

为什么我使用赛璐珞会得到随机错误?

我需要对Web服务进行API调用才能检索日期。 为此我创建了一个样本以熟悉赛璐珞。 在这里,我将使用openweather API进行“培训”。 最终目标是同时运行多个请求。 我的预订类(booking.rb)获取数据 require ‘celluloid’ require ‘open-uri’ require ‘json’ class Booking include Celluloid def initialize end def parse(url) p “back again” begin buffer = open(url).read p JSON.parse(buffer)[‘cod’] rescue => e “fuck” end end end 这就是我运行它的方式: require ‘celluloid’ Celluloid.shutdown_timeout = 10 begin pool = Booking.pool %W( http://api.openweathermap.org/data/2.5/weather?q=London,uk http://api.openweathermap.org/data/2.5/weather?q=Berlin,de http://api.openweathermap.org/data/2.5/weather?q=Munich,de http://api.openweathermap.org/data/2.5/weather?q=Munich,de http://api.openweathermap.org/data/2.5/weather?q=Munich,de http://api.openweathermap.org/data/2.5/weather?q=Munich,de http://api.openweathermap.org/data/2.5/weather?q=Munich,de […]

在轮询器内异步运行代码

在我的ruby脚本中,我使用的是celluloid-zmq gem。 我试图在pollers中使用异步运行evaluate_response, async.evaluate_response(socket.read_multipart) 但是,如果我从循环中删除睡眠,不知怎么说没有成功,它没有达到“evaluate_response”方法。 但是,如果我把睡眠放在循环内,它就能很好 require ‘celluloid/zmq’ Celluloid::ZMQ.init module Celluloid module ZMQ class Socket def socket @socket end end end end class Indefinite include Celluloid::ZMQ ## Readers attr_reader :dealersock,:pullsock,:pollers def initialize prepare_dealersock and prepare_pullsock and prepare_pollers end ## prepare DEALER SOCK def prepare_dealersock @dealersock = DealerSocket.new @dealersock.identity = “IDENTITY” @dealersock.connect(“tcp://localhost:20482”) end ## prepare PULL […]

了解赛璐珞并发

以下是我的赛璐珞代码。 client1.rb 2个客户端之一。 (我把它命名为客户1) client2.rb 2个客户中的第2个。 (命名为客户2) 注意: 上述两个客户端之间唯一的区别是传递给服务器的文本。 ie(分别是’client-1’和’client-2′ ) 在测试这2个客户端(通过并排运行)对后续2个服务器(一次一个)。 我发现很奇怪的结果 。 server1.rb ( 取自celluloid-zmq的README.md的基本示例 ) 使用此作为上述2个客户端的示例服务器导致并行执行任务。 OUTPUT ruby server1.rb Received at 04:59:39 PM and message is client-1 Going to sleep now Received at 04:59:52 PM and message is client-2 注意: client1.rb请求处于hibernate状态时处理client2.rb消息。( 并行标记 ) server2.rb 使用此作为上述2个客户端的示例服务器并未导致并行执行任务。 OUTPUT ruby server2.rb Received at 04:55:52 PM […]

ruby块内的赛璐珞异步不起作用

尝试在我的工作示例中实现Celluloid 异步似乎表现出奇怪的行为。 这里我的代码看起来 class Indefinite include Celluloid def run! loop do [1].each do |i| async.on_background end end end def on_background puts “Running in background” end end Indefinite.new.run! 但是当我运行上面的代码时,我从未看到过“ 在后台运行 ” 但是,如果我睡觉 ,代码似乎工作。 class Indefinite include Celluloid def run! loop do [1].each do |i| async.on_background end sleep 0.5 end end def on_background puts “Running in background” […]

如何处理ZeroMQ + Ruby中的线程问题?

阅读关于线程安全的ZeroMQ常见问题时偶然发现。 我的multithreading程序在ZeroMQ库中的奇怪位置不断崩溃。 我究竟做错了什么? ZeroMQ套接字不是线程安全的。 “指南”中对此进行了详细介绍。 简短版本是不应在线程之间共享套接字。 我们建议为每个线程创建一个专用套接字。 对于每个线程的专用套接字不可行的情况,当且仅当每个线程在访问套接字之前执行完整的内存屏障时,才可以共享套接字。 大多数语言都支持Mutex或Spinlock,它将代表您执行完整的内存屏障。 我的multithreading程序在ZeroMQ库中的奇怪位置不断崩溃。 我究竟做错了什么? 以下是我的以下代码: Celluloid::ZMQ.init module Scp module DataStore class DataSocket include Celluloid::ZMQ def pull_socket(socket) @read_socket = Socket::Pull.new.tap do |read_socket| ## IPC socket read_socket.connect(socket) end end def push_socket(socket) @write_socket = Socket::Push.new.tap do |write_socket| ## IPC socket write_socket.connect(socket) end end def run pull_socket and push_socket and loopify! end […]

赛璐珞gem安装出错

最近我将我的rails版本更新为4.2.3 ,将ruby版本更新为ruby-2.2.3 。 之后,当我做捆绑时,它会出现以下错误: $ bundle Fetching gem metadata from http://rubygems.org/………. Fetching version metadata from http://rubygems.org/… Fetching dependency metadata from http://rubygems.org/.. Could not find celluloid-0.16.1 in any of the sources 你可以帮帮我吗?