2021
August 05: ESP and solar panel Part 2; the results2020
December 26: ESP and solar panel Part 1; the setup August 22: ESP-8266 power issue with ME6206 regulator2019
October 18: How to use alarm syscall in Ruby2018
December 20: Decode Oregon Scientific sensors with RaspberryPi and Arduino2016
October 19: How I recovered a dead hard drive with a freezer September 28: Drawing a ground plane in Kicad June 27: Quick Ruby On Rail memo2015
December 18: Signal handling and Ruby December 14: EventMachine is good but... September 18: My custom ortholinear keyboard February 08: Quick Sinatra boilerplate2014
September 16: Wifi access point on a Raspberry Pi March 24: Linphone and G729 on Opensuse2013
November 11: Ext4 rescue tips November 05: Why this blog is'nt running Wordpress ?...not as good as Twisted.
I used to be an heavy user of Twisted framework, in Python, but as I prefer Ruby, I switched to EventMachine for one of my new project. And I have to say, I'm really disappointed. Usually, Ruby frameworks and modules are better than their equivalent in other languages, but not this time.
EventMachine is quite ok, but it miss a lot of functionalities we find in Twisted. Basic stuff, for example the ability to instantiate already fired Deferred, chain nested Deferred, join multiple Deferred in one, spawn thread that fire Deferred...
PerspectiveBroker protocol is also awesome and as no equivalent in Ruby. There is just no RPC libs for EventMachine. Generally speaking, all networking libraries are much more integrated in Twisted than their counterpart in EventMachine.
But the main missing point is the error management within the callback chain. There is just nothing helpful, you have to deal manually with exceptions.
The Twisted way, with the two cross-chained callbacks is really smart and convenient. Basically, here is how it works :
- Errback and Callback are two synchronized chains of callbacks.
- Each time one success, it execute the next callback with the result of the previous one as parameter.
- Each time one fail, it execute the next errback with the exception as parameter.
See the Twisted documentation for more details.
So I extended EM with a little bit of monkey patching to get te same behavior. You can find the gem on github: em-twistedlike. With this, development is less painful and closer to Twisted spirit but still not really enjoyable.
A reimplementation of PerspectiveBroker in EventMachine would be really nice too, but it's a lot of work, maybe another time.
Sadly, the project seems to be dead (see comments on the mailing list). I tried to get some information via IRC, no luck... Many people are forking it to add missing functionalities, for example Sensu-em and EventMachine-LE.
For new projects, some people recommend Celluloid, an implementation of the "Actor model". It's a different approach, heavily multi-threaded, but I will give it a try for my next project.