Nanite actor class method exiting upon an EM callback from EM::P::SmtpClient

1 view
Skip to first unread message

jasonjackson

unread,
Mar 10, 2010, 7:31:40 AM3/10/10
to Nanite
If i am running eventmachine inside of a nanite actor class, is there
a way to not allow the method in the actor class to return until it
gets a callback from EM? Not sure if nanite has any hooks for that..
Basically i am using EM::P::SmtpClient in an actor class, and nanite
is fetching payload over rabbitmq faster than EM is able to process
it, causing a race condition of sorts.. I need to simulate blocking
or a sleep in the actor to throttle the rate at which nanite is
fetching payload since i cant really block in EM..

What i need is to set up a callback in EM where when the SMTP client
finishes all of its email, it returns a callback which then allows the
method to exit. The problem is that because the actor class method
returns as soon as the payload is assigned to EM, nanite runs through
all of the payload in rabbitmq resulting in errors with EM not being
able to open any more sockets. Since I can't block in EM, it seems
like the most practical place to handle this is just to allow the
method in the actor class to exit after it receives the callback.
Anyone have a better idea on how to throttle this? I have this
project up on github if anyone want to take a look.


Reply all
Reply to author
Forward
0 new messages