[Rails] Re: Re: Re: Database Concurrency Without a Web Server?

Francis Cianfrocca
Thu, 13 Jul 2006 20:44:16 -0000

snacktime wrote:
> On 7/13/06, Francis Cianfrocca <garbagecat10@gmail.com> wrote:
>> > someone is using it for network connections which are already
>> > nonblocking, but also needs database or file access.  They can use
>> > threads for the stuff that isn''t yet nonblocking.
>> >
>> > Good to see an event framework started for ruby, it definitely
needed
>> > one.
>>
>> EventMachine is definitely intended to meet the needs addressed by
>> Twisted. What other features do you think are high on the list? Also,
>> can you think of any applications that would be easier to write with
>> such a Ruby framework?
>
> Maybe something like twisted has where you can specify two methods to
> a callback, one for success and one if there is an error so you can
> catch it.

I''ve thought a lot about that, and I''m not convinced
it''s necessary
because Ruby makes certain things easier than Python. What Twisted does
when it creates a deferred is give you back an object that you add your
own callbacks and errbacks to, in a chain. And you can pass it around to
other code that will add its own callbacks and errbacks. But with Ruby,
all the processing is there in the closure. EventMachine#defer as
currently implemented doesn''t return anything. It simply remembers the
callback block as the operation makes its way through the thread pool.
Whatever result was generated from the processing block gets passed to
the (single) callback, which can make its own decisions about whether an
error occurred or not.

I may be missing something, so can you think of a case where it actually
makes more sense to supply separate callbacks and errbacks?