how to use AnyEvent::Handle on the child of AnyEvent::Run (aka portable_socketpair)?
Fulko Hew
fulko.hew at gmail.com
Thu Nov 21 18:00:15 CET 2013
On Thu, Nov 21, 2013 at 9:36 AM, Marc Lehmann <schmorp at schmorp.de> wrote:
> On Thu, Nov 21, 2013 at 09:16:18AM -0500, Fulko Hew <fulko.hew at gmail.com>
> wrote:
>
... snip ...
> I think the same, that's how it is, even :)
>
> > I was hoping that a block in the backend wouldn't block 'other' backends.
>
> I would hope so, too - I wouldn't even know how one child would be able to
> block another child process or the parent.
>
I should have said 'one child blocking another child', but (more below)
... snip ...
> If you mean the child gets blocked, well, that's what your code does, and
> that is what you claimed you wanted to have, so I don't think that's what
> you mean.
>
You are correct. My problem was that I was attempting to use
Coro:async_pool
thinking that it would allow each RPC invocation to be independent from
the 'sleep blocking' perspective, but it won't be. [Coro has its own
compatible
sleep()].
> > ... I also tried creating two AnyEvent::Fork->new()
> > that I hoped would duplicate the child in which to execute
> > the RPC (similar to your Coro::async_pool), but that created
> > even more errors.
>
> You haven't mentioned any errors yet. What do you mean with "more errors"?
>
After a number of iterations, I eventually was able to get my multi-fork
ersion to work without errors, and with it, each child's RPC invocation
is indeed separate.
> With Coro's sleep, I get:
>
> Thu Nov 21 15:29:33 2013 calling add
> Thu Nov 21 15:29:33 2013 calling mul
> Thu Nov 21 15:29:33 2013 calling completed
> Thu Nov 21 15:29:33 2013 add called
> Thu Nov 21 15:29:33 2013 mul called
> Thu Nov 21 15:29:34 2013 mul returning after 1 second sleep
> mul 1,3 3
> Thu Nov 21 15:29:34 2013 mul done
> Thu Nov 21 15:29:36 2013 add returning after 3 second sleep
> add 1,3 4
> Thu Nov 21 15:29:36 2013 add done
>
> with perl sleep, I get:
>
> Thu Nov 21 15:29:54 2013 calling add
> Thu Nov 21 15:29:54 2013 calling mul
> Thu Nov 21 15:29:54 2013 calling completed
> Thu Nov 21 15:29:54 2013 add called
> Thu Nov 21 15:29:57 2013 add returning after 3 second sleep
> Thu Nov 21 15:29:57 2013 mul called
> Thu Nov 21 15:29:58 2013 mul returning after 1 second sleep
> add 1,3 4
> Thu Nov 21 15:29:58 2013 add done
> mul 1,3 3
> Thu Nov 21 15:29:58 2013 mul done
>
> In both cases the parent wasn't blocked in any way. What output do you
> get
> ?
>
In the
C
oro
-
sleep case, the RPCs returned in
t0+1 and t0+3 seconds (as intended).
In the Perl-sleep case they return in t0+3 and t0+3+1 seconds.
Its not that the parent ended up being blocked, but the child/child-pool
activity was (as I suppose they would be, its just that I hadn't yet figured
out how to code/include what I wanted).
The newly attached version (because I now have two separate forked
children (instead of using async_pool)) works the way I need, just like the
Coro timing.
Now back to adding the data-passing parts back in. :-)
Thank you for your ongoing help!
Fulko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20131121/3f7c9677/attachment-0001.html>
More information about the anyevent
mailing list