bfg / mojox-run

MojoX::Run - asynchronous external command execution for Mojo
5 stars 3 forks source link

Some issues #1

Open sharifulin opened 13 years ago

sharifulin commented 13 years ago

Hi!

MojoX::Run is good stuff for Mojo, thanks!

  1. I try run a perl code and want get any perl structure. For example POE::Wheel::Run or Mojolicious::Sessions uses Storable. Do you plan add this feauture into MojoX::Run?
  2. exit 0 in perl sub is bad idea, maybe return in sub and always exit 0 in MojoX::Run's wrapper.
  3. chmod for stderr and stdout
bfg commented 13 years ago

1. POE::Wheel::Run supports storable trough POE::Filter filters. If you want to get perl structure, just print it out in sub with Data::Dumper, collect input using MojoX-Run, then

local $@; my $h = eval $str; if ($@) { die "Bad data: $@"; }

else enjoy your shiny hash.

Reading binary data from spawned process should also work.

  1. There is nothing wrong with exit 0 in perl sub if sub is spawned in separate process.
  2. chmod for stderr/stdout?

What do you mean? You want to redirect output to file and you want that mojox-run should set permissions on that file? I guess that this is also bad idea...

Please give me some use cases for your wishes; i'll check what i could do about it.

regards, Brane

sharifulin commented 13 years ago
  1. I know, there are a lot of space and \n after dumper. Would be nice if Storable will be in box.
  2. sorry, chomp
bfg commented 13 years ago

So you want to run some sub in subprocess, return some complex data from it and you want that parent would get that data in natural form?

something like this:

my $pid = $mojoxrun->spawn_sub(
    sub { return { a => rand(), b => rand() } },
    exit_cb => sub {
          my ($pid, $res, $exception) = @_;
          # $res holds hash reference returned by sub
    }
);

?

sharifulin commented 13 years ago

Yes, it's simple and powerful :)

bfg commented 13 years ago

OK, seems reasonable, i'm going to implement it.

bfg commented 13 years ago

spawn_sub implemented in version 0.15. It may take several hours to be available from CPAN.

sharifulin commented 13 years ago

Good, I'll try it, thanks.

sharifulin commented 12 years ago

I like this thread :) bfg, does MojoX::Run work with Mojolicious 1.98 ?

bfg commented 12 years ago

sharifulin, as you can see from this thread, it doesn't. I'll fix it in a day or two :)

In the mean time, you can install EV, use EV Mojo::IOLoop implementation and spawn processes using AnyEvent::Subprocess, AnyEvent::Run, or simple AnyEvent::Util::run_cmd to spawn external process/sub.

sharifulin commented 12 years ago

Thanks, Brane.

What's a pity, MojoX::Run is good stuff, I like it! :)

On Wed, Sep 21, 2011 at 4:30 PM, Brane F. Gračnar < reply@reply.github.com>wrote:

sharifulin, as you can see from this thread, it doesn't. I'll fix it in a day or two :)

In the mean time, you can install EV, use EV Mojo::IOLoop implementation and spawn processes using AnyEvent::Subprocess, AnyEvent::Run, or simple AnyEvent::Util::run_cmd to spawn external process/sub.

Reply to this email directly or view it on GitHub: https://github.com/bfg/mojox-run/issues/1#issuecomment-2155409

С уважением, Анатолий Шарифулин.

bfg commented 12 years ago

Do you use EV backend? It seems that Mojolicious 1.65 broke non-socket fh support in IOLoop...

I'm getting:

Write failed: Can't call method "_connecting" on an undefined value at /usr/lib/perl5/site_perl/5.12.3/Mojo/IOLoop/Client.pm line 129.

I'm asking this because i'm thinking about implementing MojoX::Run on top of EV, which has stable interface... What do you think about depending MojoX::Run to EV?

sharifulin commented 12 years ago

Good idea. I'll use EV backend in MojoX::Run :)