Group: http://groups.google.com/group/nanite/topics
jasonjackson <jasonj...@gmail.com> Mar 10 04:31AM -0800 ^
--
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.
You received this message because you are subscribed to the Google Groups "Nanite" group.
To post to this group, send email to nan...@googlegroups.com.
To unsubscribe from this group, send email to nanite+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nanite?hl=en.
The inherent problem at hand is that EventMachine just wasn't built to
be blocking. It basically forfeits the whole purpose of how Nanite
works. The closest I could think of to make the agent running
single-threaded and set prefetch to 1, so that message trickle in
serialized. Other than that your closest bet would be to put the
thread to sleep, but that's just not great. Otherwise you'd have to
build in some EM-based mechanism based on e.g. a queue that checks if
a job is running and defers execution of others until that's done.
> http://dotrb.com/blogs/55/posts/141
>
Thanks for the write-up! Would be nice to be able to read this without
having to sign up.
Cheers, Mathias
--
http://twitter.com/roidrage