EventMachine & EM.defer

I’m stuck using EM.defer.

I am trying to use EM.defer simply to thread a bunch of processing for
now (more complicated plans, but this is the problem so the use case is
simplified). I have it deferring and threading, but not calling back
successfully (to the main loop) and ending the reactor loop. What am I
doing wrong? All code, and sample command line output in this pastie.
Should be easy for someone with EM experience to troubleshoot… help?



I’m on my phone right now so I can’t try your code nor can I even read
it very clearly.

However, I just wanted to point out a problem I encountered when I
first used Deferrable that may or may not help.

Each time Deferrable#success or Deferrable#failure is called, all the
callbacks/errbacks are called AND THEN DESTROYED. Thus, your callbacks
may only get executed once unless they are somehow added to the
Deferrable object again.

My way around this was to use a Channel instead of success/callback.