Questions tagged [eventmachine]

EventMachine is a fast, reactor pattern library for Ruby programs. It provides non-blocking IO APIs with transparent internal buffers and standard reactor features (such as defer, next_tick and timers). (note to future editors: Eventmachine itself does not use Fibers, and the core does not use threads for any IO, timers or core infrastructure).

EventMachine is a fast, reactor pattern library for Ruby programs.

627 questions
0
votes
3 answers

em-simple_telnet.rb error 'pause_and_wait_for_result'

Towards a MUD client, I'm using telnet. I'm trying to get the weather like Apache does, but this error seems to, probably, be that I'm not using the em-simple_telnet API correctly. error: thufir@dur:~/ruby$ thufir@dur:~/ruby$ ruby weather.rb…
Thufir
  • 8,216
  • 28
  • 125
  • 273
0
votes
1 answer

Use eventmachine with sinatra, why it will always quit?

why it always quit when i run this ruby program ? This is the ruby program: require 'rubygems' require 'eventmachine' require 'thread' require 'sinatra' Thread.new do EventMachine.run do EM.add_periodic_timer(1) do #do some…
kevin
  • 3
  • 2
0
votes
1 answer

Why does Ruby's EventMachine.defers_finished?() sometimes return true when not all defers are complete?

Sample code: require 'eventmachine' t = Thread.new { EM.run } op = proc { op2 = proc { sleep 1 puts 'op2 finishing' } cb2 = proc { sleep 1 puts 'cb2 finishing' } EM.defer(op2, cb2) puts 'op finishing' } cb = proc { …
ralfthewise
  • 543
  • 7
  • 10
0
votes
1 answer

Using WebSockets with EM and IRC to Send "Connection Successful" Message

I'm attempting to write an IRC client using WebSockets. The IRC client I found on GitHub uses EventMachine, but I'm trying to use WebSockets as well to notify any connected clients when they're connected. However, I don't think I'm quite…
Wildhoney
  • 4,969
  • 33
  • 38
0
votes
1 answer

Eventmachine: Escapes received binary data

I'm using EventMachine tutorial as a starting point to experiment with sending / receiving binary data. The sample code is: #!/usr/bin/env ruby require 'rubygems' # or use Bundler.setup require 'eventmachine' class EchoServer < EM::Connection …
Misha M
  • 10,979
  • 17
  • 53
  • 65
0
votes
1 answer

AMQP/RabbitMQ-Server/EventMachine with PhusionPassenger/Rails Can Only Receive the First Message

I'm using AMQP / RabbitMQ for my Ruby on Rails app. I put the following amqp.rb file under config/initializers: (Copied and changed from a Recipe: http://www.hiringthing.com/2011/11/04/eventmachine-with-rails.html#sthash.iqCWUtOn.dpbs) require…
Peter Lee
  • 12,931
  • 11
  • 73
  • 100
0
votes
1 answer

AMQP/RabbitMQ-Server/EventMachine with PhusionPassenger/Rails Crashes

I'm using AMQP / RabbitMQ for my Ruby on Rails app. I put the following amqp.rb file under config/initializers: (Copied and changed from a Recipe: http://www.hiringthing.com/2011/11/04/eventmachine-with-rails.html#sthash.iqCWUtOn.dpbs) require…
Peter Lee
  • 12,931
  • 11
  • 73
  • 100
0
votes
2 answers

Why my eventmachine client code doesn't work asynchronously?

def index p "INDEX, #{Fiber.current.object_id}" # <- #1 EventMachine.run { http = EventMachine::HttpRequest.new('http://google.com/').get :query => {'keyname' => 'value'} http.errback { p "Uh oh, #{Fiber.current.object_id}"; EM.stop } #…
Benjamin
  • 10,085
  • 19
  • 80
  • 130
0
votes
1 answer

em-synchrony using http.get and iterators causing can't yield in root Fiber error

A very simple case where I get the root Fiber error. require 'em-synchrony' require 'em-synchrony/em-http' urls = %w{http://www.google.com http://www.google.com http://www.google.com http://www.google.com http://www.google.com…
keaplogik
  • 2,369
  • 2
  • 25
  • 26
0
votes
1 answer

Streaming socket service with EventMachine in Ruby not working

I have the following EventMachine-based Ruby client, but nothing outputs when it connects to the server: EventMachine.run do conn = EventMachine::HttpRequest.new('http://localhost:10000') http = conn.get http.stream do |data| puts data #…
Chad Johnson
  • 21,215
  • 34
  • 109
  • 207
0
votes
0 answers

How to recover a crashed EventMachine loop

I'm using Unicorn on Heroku and I created an EventMachine loop: (from https://gist.github.com/jonkgrimes/5103321) after_fork do |server,worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection if…
Chris Doyle
  • 1,029
  • 12
  • 15
0
votes
1 answer

Eventmachine calls callback twice

I tried to launch eventmachine httpserver example, but I've added simple puts in the process_http_request method. To my surprise, when I access localhost:8080 from browser, I see puts output in terminal twice. Why is it printed twice? Is it a bug?…
Shamir K.
  • 385
  • 2
  • 7
0
votes
2 answers

Does this block the event loop?

I have a sinatra app that is using thin as it's web server. I interact with my database via ActiveRecord. If in an endpoint, I do this: get '/test' do Model.create(.....) end Does the Model.create(.....) block the event loop (thin uses…
0xSina
  • 20,973
  • 34
  • 136
  • 253
0
votes
2 answers

Running EventMachine in new Thread after Rails is loaded using Thin

I have a Rails 3.2 app running on a Thin server and in application.rb I want to start EventMachine: # application.rb config.after_initialize do if ENV['EM'] EM.run do host = '0.0.0.0' port = 3001 # hit Ctrl + C to stop …
Flauwekeul
  • 869
  • 7
  • 24
0
votes
1 answer

Debugging Stuck Ruby Process - Workling\Starling

We have a rails app that about every 24 hours runs the load average on the machine well beyond 5. It looks like a stuck Ruby process specifically related to a background process running to manage event and calendar reminders. It seems like killing…
daved82
  • 23
  • 3