Francis Cianfrocca
2007-Dec-13 16:47 UTC
[Eventmachine-talk] Some new syntax for child processes
All, I know we''re still discussing several issues regarding EM#popen, so just to muddy the water :-), I added a sugaring for the use case in which you want to fork the child and be notified when it terminates. EM.run { d = EM::DeferrableChildProcess.open( "ls -ltr" ) d.callback {|response| puts response } } This is not appropriate, of course, for cases when the child process will generate data periodically over a long period. For that case, we will want to pass a block that will get yielded to when the child process emits data. The new class does NOT yet have a method for passing data into the child process. But that will be easy enough. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071213/2ae475df/attachment.html
Tony Arcieri
2007-Dec-13 17:42 UTC
[Eventmachine-talk] Some new syntax for child processes
On Dec 13, 2007 5:47 PM, Francis Cianfrocca <garbagecat10 at gmail.com> wrote:> All, I know we''re still discussing several issues regarding EM#popen, so > just to muddy the water :-), I added a sugaring for the use case in which > you want to fork the child and be notified when it terminates. > > EM.run { > d = EM::DeferrableChildProcess.open( "ls -ltr" ) > d.callback {|response| > puts response > } > } > > > This is not appropriate, of course, for cases when the child process will > generate data periodically over a long period. For that case, we will want > to pass a block that will get yielded to when the child process emits data. > > The new class does NOT yet have a method for passing data into the child > process. But that will be easy enough. > > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >-- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071213/af39181f/attachment.html
Tony Arcieri
2007-Dec-13 17:44 UTC
[Eventmachine-talk] Some new syntax for child processes
Whoops... sorry about the blank message. So this could, in theory, be used with Rails + Evented Mongrel to call out to a background process you wish to run (i.e. start a job), have Rails return a response to the request, and then have Rails do something with the response once complete? That would be *extremely* useful for what we''re doing. On Dec 13, 2007 6:42 PM, Tony Arcieri <tony at clickcaster.com> wrote:> > > On Dec 13, 2007 5:47 PM, Francis Cianfrocca <garbagecat10 at gmail.com> > wrote: > > > All, I know we''re still discussing several issues regarding EM#popen, so > > just to muddy the water :-), I added a sugaring for the use case in which > > you want to fork the child and be notified when it terminates. > > > > EM.run { > > d = EM::DeferrableChildProcess.open( "ls -ltr" ) > > d.callback {|response| > > puts response > > } > > } > > > > > > This is not appropriate, of course, for cases when the child process > > will generate data periodically over a long period. For that case, we will > > want to pass a block that will get yielded to when the child process emits > > data. > > > > The new class does NOT yet have a method for passing data into the child > > process. But that will be easy enough. > > > > _______________________________________________ > > Eventmachine-talk mailing list > > Eventmachine-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/eventmachine-talk > > > > > > -- > Tony Arcieri > ClickCaster, Inc. > tony at clickcaster.com-- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071213/05a76674/attachment.html