Re: [Mojolicious] Time limit a slow process?

2019-02-08 Thread Jason Crowther

>
> Is Minion  an option for you?  By 
> default it depends on a Pg instance, but I'm pretty sure that there's at 
> least a SQLite backend available on CPAN as well.
>

Hi Stefan, I think I might end up using Minion eventually, but I'm hoping I 
can get away with something quick and dirty for now.  Thanks!  -=>j 

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Time limit a slow process?

2019-02-08 Thread Stefan Adams
On Fri, Feb 8, 2019 at 7:36 AM Jason Crowther 
wrote:

> doSlowWork()  doesn't need to return anything (output is polled for
> elsewhere.)
>

Is Minion  an option for you?  By
default it depends on a Pg instance, but I'm pretty sure that there's at
least a SQLite backend available on CPAN as well.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Time limit a slow process?

2019-02-08 Thread Jason Crowther
I'd like to fire and forget a process, but put a timeout on how long that 
process can run.  It's easy enough to kick off a process 
with Mojo::IOLoop::ForkCall (deprecated) or Mojo::IOLoop::Subprocess, but I 
can't find any examples of adding a timeout.

Here's some pseudo code for what I'm looking for:

get '/background' => sub {
my $c = shift;
my $subprocess = Mojo::IOLoop::Subprocess->new;
$subprocess->run(
sub {
# limit how long the following sub should run
doSlowWork();
return 1;
},
sub { # required, even if you don't use it
my ($subprocess, $err, @results) = @_;
}
);
$subprocess->ioloop->start
unless $subprocess->ioloop->is_running;
$c->render( text => q|background process started|);
};

doSlowWork()  doesn't need to return anything (output is polled for 
elsewhere.)

Can someone point me in the right direction?  Thanks!

-=>j

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.