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

Way to persist ruby objects that get their state changed via game ticks

Context I'm making a game in ruby. It has a model named Character with attributes like energy and money. A Character can have a behavior, e.g. sleeping. Finally the Character has a tick method that calls its behavior method sleep!. Simplified it…
Flauwekeul
  • 869
  • 7
  • 24
0
votes
2 answers

How to avoid the source being overwritten when compiling a Gem?

I am trying to install eventmachine Gem, however a line needs to be commented out in the source for this to work on Ruby 2.0 on Windows x64. I have tried modifying the Gem source in the Ruby build folder but each time I run gem install eventmachine…
Brendan
  • 18,771
  • 17
  • 83
  • 114
0
votes
1 answer

EventMachine & Live Reload

I am running a daemon which uses eventmachine. It must have 100% uptime, even while I re-deploy my code. So I am looking for zero-downtime deploys. Is there a way to make EventMachine reload the code without losing connections? I thought about…
iblue
  • 29,609
  • 19
  • 89
  • 128
0
votes
1 answer

How to read and process a file in Ruby with EventMachine

I am wondering if anybody figured out a way to process bigger (500Mb+) text files with EventMachine, where you actually need to access the individual lines.
Istvan
  • 7,500
  • 9
  • 59
  • 109
0
votes
1 answer

How to use eventmachine, rails, and websockets?

i have the following sinatra code, how do i do the equivalent but for a rails app? specifically, want to start rails with thin inside the reactor loop, while also using a websocket server in there too. require 'bundler' Bundler.require class App <…
horseyguy
  • 29,455
  • 20
  • 103
  • 145
0
votes
2 answers

Return eventmachine output to object in Ruby

In the below function (which is defined inside a class Myclass) I can run the function in ruby like myoutput = Myclass.get_par("http://eol.org/api/ping/1.0.json,http://eol.org/api/ping/1.0.json") and the output of the calls gets printed to the…
sckott
  • 5,755
  • 2
  • 26
  • 42
0
votes
2 answers

eventmachine callback declaration order

In all eventmachine code that I've seen, the callbacks / errorbacks were declared after the actual call of the method. Here's a simple example: about = EventMachine::HttpRequest.new('http://google.ca/search?q=eventmachine').get about.callback {…
jli_123
  • 215
  • 1
  • 4
0
votes
1 answer

rails method chaining context

I have what is probably a basic Q, but it appears complex in the setup. I have a module that has some classes. One class contains methods for API calls. Other classes describe a server. Dev for instance has its attributes. The server classes inherit…
sam452
  • 1,281
  • 3
  • 20
  • 33
0
votes
1 answer

This eventmachine code serves only one client and only once

I'm a complete newbie in this & I made a simple code that fetches data from RabbitMQ and sends it to client connected via websockets. Problem here is: if I start a app and a client connects (in browser) it sends data and everything goes fine.…
shadyabhi
  • 16,675
  • 26
  • 80
  • 131
0
votes
1 answer

custom_require.rb load error in eventmachine installation

I'm having a problem with my gems dependencies: the content of the Gemfile is source :gemcutter gem "sinatra" gem "koala" gem "json", "1.5.5" gem "httparty" gem "thin" gem "rack", "1.3.10" And a bundle install hit me with this error $ sudo bundle…
Metz
  • 675
  • 1
  • 9
  • 17
0
votes
2 answers

Ruby: EventMachine and separate callback queues

EventMachine executes all operations in separate threads and all callbacks of this operations in one mainthread. It's very useful when you need reduce competitiveness in data processing between portions of data. You can recieve data from network…
everm1nd
  • 731
  • 7
  • 14
0
votes
1 answer

Linux Environment Variables in EventMachine run loop

I have a simple ruby file that uses Eventmachine for to act as a daemon. It look like this: ... EM.run { Signal.trap('INT') { @log.debug("trapped INT signal"); stop(true) } Signal.trap('TERM') { @log.debug("trapped TERM signal"); stop(true)…
Khash
  • 2,500
  • 4
  • 30
  • 56
0
votes
1 answer

how does this eventmachine code work

In the code below, I read from a redis queue and trigger callbacks on a local deferrable variable d when the redis operation completes. It works fine, but I expected to get an error because when the method f returns the variable d goes out of scope.…
akonsu
  • 28,824
  • 33
  • 119
  • 194
0
votes
2 answers

eventmachine: how to be concurrency?

Here is my code, I use sleep to simulate a long running request require 'eventmachine' def test (i) puts "#{i} start to sleep..." sleep i puts "#{i} end..." end EventMachine.run do (1..3).each do |i| test i end …
Sato
  • 8,192
  • 17
  • 60
  • 115
0
votes
3 answers

Thin + EventMachine fails to start

While loading a Thin webserver for a sinatra app I keep getting Unable to load the EventMachine C extension; To use the pure-ruby reactor, require em/pure_ruby'/vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.0.rc.4/lib/eventmachine.rb:8:in…
Nuno Valente
  • 35
  • 1
  • 4