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
1 answer

Using Rmagick with eventmachine

I am trying to create a very simple web service with Goliath and Grape. All that my service would do is that given an image path and a target dimension it would return the new geometry of the image. The images are stored in the same server as the…
Lester Celestial
  • 1,454
  • 1
  • 16
  • 26
0
votes
1 answer

Is there any way to find pid for eventmachine's popen?

In ruby standard library, popen return a object which has pid method, In eventmachine, popen return a Connection object which contain no process id information. Demo code here: require 'eventmachine' def work s = EM.popen('ls') puts s.pid # how…
linjunhalida
  • 4,538
  • 6
  • 44
  • 64
0
votes
1 answer

EventMachine change delay in a periodic timer inside the block

Call a periodic timer and when an error occurs inside the block change this the periodic timer delay. Can i use periodic timer or the best way is an add_timer ? Hi, i want to do this: EventMachine.run EventMachine.add_periodic_timer 1 …
andrea
  • 381
  • 5
  • 23
0
votes
2 answers

Run websocket onmessage in different thread

I am using websocket on a server as below. It responds to onmessage events, and are conditioned to do different tasks according to the message: require "websocket-eventmachine-server" WebSocket::EventMachine::Server.start(host: some_server_name,…
sawa
  • 165,429
  • 45
  • 277
  • 381
0
votes
2 answers

Howto know that I do not block Ruby eventmachine with a mongodb operation

I am working on a eventmachine based application that periodically polls for changes of MongoDB stored documents. A simplified code snippet could look like: require 'rubygems' require 'eventmachine' require 'em-mongo' require 'bson' EM.run { @db…
GeorgieF
  • 2,687
  • 5
  • 29
  • 43
0
votes
1 answer

How to deploy a non-http EventMachine based service on Passenger

There are examples how to deploy an EM based service alongside a normal HTTP service, backed by Passenger, eg EventMachine and Passenger. The HTTP component is activated by the HTTP service (nginx, apache), hosted/monitored by Passenger, and this…
Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
0
votes
1 answer

cramp framework sync 'render' correct way using em-synchrony

To describe my problem I attach simple Cramp http://cramp.in/ class. I add some modification but its mainly work like https://github.com/lifo/cramp-pub-sub-chat-demo/blob/master/app/actions/chat_action.rb class ChatAction < Cramp::Websocket …
mateuszdw
  • 61
  • 1
  • 8
0
votes
0 answers

Tornado vs eventmachine

To get good performance in ruby eventmachine you need to apply rules like: don't block reactor using em drivers to everything that system uses Does similar rules apply to Python's Tornado library?
Sławosz
  • 11,187
  • 15
  • 73
  • 106
0
votes
1 answer

Eventmachine failed to work when system time changed earlier

When running the following popular eventmachine example: require 'rubygems' require 'eventmachine-le' EM.run do p = EM::PeriodicTimer.new(1) do puts "Tick ..." end EM::Timer.new(100) do puts "BOOM" p.cancel end …
cokecike
  • 11
  • 2
0
votes
2 answers

How to return MySQL query results from EventMachine?

I'm trying to use EM::Synchrony to speed up my queries by making them async. Following along with the examples from the github page here I'm making 2 asynchronous queries: EventMachine.synchrony do db =…
Evan Zamir
  • 8,059
  • 14
  • 56
  • 83
0
votes
1 answer

Hanging MySQL2 connections spun up in EventMachine

I'm running this code from the mysql2 gem docs: require 'mysql2/em' EM.run do client1 = Mysql2::EM::Client.new defer1 = client1.query "SELECT sleep(3) as first_query" defer1.callback do |result| puts "Result: #{result.to_a.inspect}" …
Evan Zamir
  • 8,059
  • 14
  • 56
  • 83
0
votes
2 answers

How can I compare the eventmachine thread power in ruby

I wrote this code about ruby thread to open 50 threads and every thread wait for 2s. #!/home/sun/.rvm/rubies/ruby-1.9.3-p448/bin/ruby ts = [] 50.times do |p| ts << Thread.new do sum = 0 5.times do |i| sleep(2) …
wonderflow
  • 665
  • 2
  • 7
  • 18
0
votes
1 answer

Testing EventMachine timers with rspec

I have a method like this: def my_method(id) EventMachine.add_periodic_timer(10) do my_other_method(id) end end (Obviously simplified.) How would I write an rspec test to check my_other_method() is called? Or that this happens repeatedly?…
Phil Gyford
  • 13,432
  • 14
  • 81
  • 143
0
votes
0 answers

EventMachine -- Blocking main thread?

I'm doing the following in Ruby Eventmachine to give me a status output every 5 seconds: def status_output puts Time.now.to_s EM::Timer.new(5) { status_output } end EM::run do status_output end It's working fine, but when I'm adding "work"…
Benedikt B
  • 733
  • 8
  • 23
0
votes
1 answer

EventMachine tick interval?

there is a method EventMachine.next_tick (http://eventmachine.rubyforge.org/EventMachine.html#next_tick-class_method). How big is the tick interval? How to control it? Can the tick interval be set?
akonsu
  • 28,824
  • 33
  • 119
  • 194