Re: Digest for nanite@googlegroups.com - 1 Message in 1 Topic

1 view
Skip to first unread message

Jason

unread,
Mar 29, 2010, 2:19:29 PM3/29/10
to nan...@googlegroups.com
I posted the code to github with a blog post that describes some of the challenges I had with nanite and eventmachine.  Was wondering if anyone has any input on a solution on how to block on a nanite actor class containing EM code as i described in the post.

Thanks,









On Thu, Mar 11, 2010 at 5:40 AM, <nanite+...@googlegroups.com> wrote:

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.



--
Most people are born and years later die without really having lived at all. They play it safe and tiptoe through life with no aspiration other than to arrive at death safely. -- Tony Campolo, "Carpe Diem"

Mathias Meyer

unread,
Mar 30, 2010, 3:43:38 AM3/30/10
to nan...@googlegroups.com
On Mon, Mar 29, 2010 at 8:19 PM, Jason <jasonj...@gmail.com> wrote:
> I posted the code to github with a blog post that describes some of the
> challenges I had with nanite and eventmachine.  Was wondering if anyone has
> any input on a solution on how to block on a nanite actor class containing
> EM code as i described in the post.

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

Reply all
Reply to author
Forward
0 new messages