Need advice with async operation

60 views
Skip to first unread message

Ivan Korjavin

unread,
Sep 15, 2013, 2:53:36 AM9/15/13
to mojol...@googlegroups.com
Need advice about best way to set up async operation in my controller,

like: 

sub process{
   my $self=shift;
   my $id=$self->stash('id');
    
    #some async method started here with $id
    async($id);
    $self->render( text => 'ok,started');
}

How I can do async method?

sri

unread,
Sep 15, 2013, 5:01:23 PM9/15/13
to mojol...@googlegroups.com
Job queues are commonly used for that. (i'll release one optimized for Mojolicious in the next few months)

--
sebastian

Sergey Dmitriev

unread,
Sep 16, 2013, 1:33:12 AM9/16/13
to mojol...@googlegroups.com

You need a job queue. E.g  TheSchwartz or another one, depending on requirements.

15.09.2013 10:53 пользователь "Ivan Korjavin" <korj...@gmail.com> написал:
--
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...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.

Ivan Korjavin

unread,
Sep 16, 2013, 3:00:26 AM9/16/13
to mojol...@googlegroups.com
Thank you all.

But if I have only one job in situation - joq queue is a overhead, is not?

I have an idea, do the route to some controller, put task into it, and do mojo-ua->get for start the job.

Is that bad? Will that be async? 

воскресенье, 15 сентября 2013 г., 12:53:36 UTC+6 пользователь Ivan Korjavin написал:

Sergey Dmitriev

unread,
Sep 16, 2013, 3:18:15 AM9/16/13
to mojol...@googlegroups.com

Anyway, for full async for incoming tasks you have to have standalone separate unix process or thread (which is ugly).If queue seems overhead for task, you can run kind of script periodically from cron to deal with.

16.09.2013 11:00 пользователь "Ivan Korjavin" <korj...@gmail.com> написал:
--
Reply all
Reply to author
Forward
0 new messages