Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Note: Eventless is unmaintained. You definitely shouldn't use it for anything.

Eventless aspires to be a concurrent networking library for Ruby that lets you write asynchronous, event driven code that looks like normal, blocking code. It uses Fibers, so it requires Ruby 1.9. It also uses Marc Lehmann's libev via Tony Arcieri's Eventless is inspired heavily by gevent.

Right now it's more of an experiment than an actual library, but I'm working hard on that.

##How it works

Eventless monkey patches Socket to make its API asynchronous. All of your code runs in a Fiber. You can make new fibers using Eventless.spawn. will not work. Your code should look exactly the same, but when you call something that normally blocks, your fiber gets put to sleep on the event loop and gets woken up when there is data to be read or written.

##How to use it

Because Eventless monkey patches the core library (eww, gross, I know), any networking library that is written in pure Ruby should just work (tm). Currently Eventless has enough code in it to support open-uri, so you can do things like this:

require 'eventless'
require 'open-uri'

fibers = %w( do |url|
  Eventless.spawn do
    open("http://#{url}/") { |f| puts }

fibers.each { |f| f.join }

You can also do this, which is admittedly, pretty silly:

require 'eventless'

fibers = []
5.times do
  fibers << Eventless.spawn { sleep 2 }

fibers.each { |f| f.join }

Even though you've spawned five fibers that sleep for two seconds a piece, this code should only take two seconds to run.


Eventless has very experimental support for monkeypatching to spawn a Fiber instead, effectively turing multithreaded programs into single threaded, evented programs. It's incompatible with Eventless::ThreadPool which is required for the DNS resolver, so it's currently disabled.


It will probably crash or not work, but:

$ git clone git://
$ cd eventless
$ bundle install
$ rake compile
$ cd examples # run some of these


This doesn't really work yet, but here's the start. Eventless is going to test against rubyspec. Here's how you do it:

$ rake spec:deps # clones rubyspec and mspec
$ rake spec # right now this just runs the socket specs without eventless

By default mspec will test against the ruby binary. You can specify the binary name or path by setting TARGET:

$ TARGET=ruby19 rake spec
$ TARGET=/usr/local/bin/ruby rake spec

Remember, right now Eventless only works on Ruby 1.9.


###What works

  • The event loop
  • Exception handling in Fiber
  • Kernel#sleep
  • Socket#recv, Socket#connect, Socket#write, and
  • IO#read* and IO#sysread (for sockets only)
  • IO#get* (but I haven't really tested them)
  • IO#write*
  • timeout.rb
  • open-uri
  • DNS resolution with a thread pool resolver for IPSocket.getaddress, Socket.pack_sockaddr_in, Addrinfo.getaddrinfo, Addrinfo.getnameinfo and Addrinfo.foreach

###What doesn't work

  • All the other Socket code.
  • All other DNS resolution
  • Everything else


The current goal is to replace all blocking methods in Socket with API compatible versions that transfer control to the event loop rather than block. When in doubt, read the code for gevent, but write your code like a Rubyist would.

Currently we are trying to monkey patch all the methods in the stock Ruby socket library. The script in script/socket_coverage.rb can be used to how many methods have and have not been reimplemented eventless' socket library:

$ ruby script/socket_coverage.rb
Eventless::BasicSocket is 17.39% complete [4/23]
Eventless::Socket is 16.22% complete [6/37]
Eventless::IPSocket is 50% complete [2/4]
Eventless::TCPSocket is 0% complete [0/1]
Eventless::TCPServer is 25% complete [1/4]
Eventless::UDPSocket is 0% complete [0/4]

The -v option can be used for a more verbose output, which includes method names:

$ ruby script/socket_coverage.rb -v
Eventless::BasicSocket is 17.92% complete [19/106]


Eventless is licensed under the MIT License. See LICENSE for more information.


An Eventlet/Gevent inspired asynchronous, event driven networking library for Ruby







No releases published


No packages published