eventmachine

How do EventMachine & Rails integrate?

I've found plenty of articles showing me what EventMachine is and how to set up endless "Hello World!" examples, but I'm still at a loss as to how this integrates with my Rails application. As a example, I have an existing Rails app that has many concurrent users who may be editing the same row in my database simultaneously. I was think...

EventMachine Question

I'm working on creating a background script that uses EventMachine to connect to a server with WebSockets. The script will be run using DelayedJob or Resque. I've been able to get it to talk to the WebSockets server and send messages, but whenever an error is raised within the EventMachine loop it doesn't crash the script - which is what...

Sending a hash using eventmachine

I want to send a hash populated with data from a EventMachine client to a server. The problem is that the server receive_date method just prints a string. The server: def receive_data(data) send_data("Ready") puts data[:total] end The client: def receive_data(data) send_data( get_memory() ) end def get_memory sigar ...

Non-blocking IO with Ruby?

I have some questions about non-blocking IO: If I use Ruby without EventMachine on Nginx, could I leverage non-blocking IO? If i use Ruby with EventMachine but on Apache, could I leverage non-blocking IO? If the above answers are no, then it means I have to use Ruby with EventMachine on Nginx to leverage non-blocking IO? ...

Ruby on Rails + EventMachine?

I've heard that you have to use non-blocking code throughout the application to be able to harness true power of EventMachine. Does this mean I can't run Ruby on Rails with EventMachine? ...

Ruby eventmachine error: 'no loop breaker'

I get a slightly heisen error from eventmachine (0.12.10, on OSX 10.6.4): terminate called after throwing an instance of 'std::runtime_error' what(): no loop breaker It only occurs in tests, and only when all tests are run together. Run individually they pass. I spotted the only place in the eventmachine code that mentions the err...

Asynchronously iterating over the response of a request using Thin and Sinatra

If your response in Sinatra returns an 'eachable' object, Sinatra's event loop will 'each' your result and yield the results in a streaming fashion as the HTTP response. However, if there are concurrent requests to Sinatra, it will iterate through all the elements of one response before handling another request. If we have a cursor to ...

One question with EventMachine

require 'eventmachine' module EchoServer def post_init puts "-- someone connected to the echo server!" end def receive_data data send_data ">>>you sent: #{data}" close_connection if data =~ /quit/i end def unbind puts "-- someone disconnected from the echo server!" end end class ...

Eventmachine::defer + ruby

I been Using EventMachine for quite a while a know and I really found it great as It Manage show much more me that i didn't have to worry for anything.But recently I just found this weird issue which i just fail to understand Here what is just telling I have Eventmachine loop Which look like this EventMachine::run { EventM...

Ruby concurrency/asynchronous processing (with simple use case)

I was looking into ruby's parallel/asynchronous processing capabilities and read many articles and blog posts. I looked through EventMachine, Fibers, Revactor, Reia, etc, etc. Unfortunately, I wasn't able to find a simple, effective (and non-IO-blocking) solution for this very simple use case: File.open('somelogfile.txt') do |file| wh...

How to get an HTTPS request with SSL client cert to work with Ruby EventMachine

I am trying to access an HTTPS web service that uses SSL cert authentication using Ruby EventMachine but I am not getting it to work. I have written the following simple code block to test it end-to-end: require 'rubygems' require 'em-http' EventMachine.run do url = 'https://foobar.com/' ssl_opts = {:private_key_file => '/tmp/priv...