metaperl has asked for the wisdom of the Perl Monks concerning the following question:

is MojoX::Run really asynchronous

In looking at the SYNOPSIS example for MojoX::Run
# 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"; }
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

synchronous shell usage

I like the API for MojoX::Run quite a bit. It makes the calling of shell commands succinct, handling the capture of STDERR and STDOUT, etc. Is there a similar tool on CPAN for synchronous shell usage?



The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

-- 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