metaperl has asked for the wisdom of the Perl Monks concerning the following question:
I'm wondering what is asynchronous about its usage. The reason that I say this is because of the line unless ($pid) which to me implies that line does not execute until the exit callback fires - there is no other way for $pid to be bound until then# create async executor SINGLETON object my $mojox_run = MojoX::Run->singleton(); # simple usage my $pid = $mojox_run->spawn( cmd => "ping -W 2 -c 5 host.example.org", exit_cb => sub { my ($pid, $res) = @_; print "Ping finished with exit status $res->{exit_val} +.\n"; print "\tSTDOUT:\n$res->{stdout}\n"; print "\tSTDERR:\n$res->{stderr}\n"; } ); # check for injuries unless ($pid) { print "Command startup failed: ", $mojox_run->error(), "\n"; }
-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: synchronous shell usage; is MojoX::Run really asynchronous
by metaperl (Curate) on Apr 28, 2011 at 19:00 UTC |