Home: Perl Programming Help: Advanced:
Non blocking IO in perl



rprasad
New User

Apr 1, 2014, 12:17 AM


Views: 22537
Non blocking IO in perl

Hi
I have a program that runs in a continuous loop
-----
Pick one job from a Redis using BLPOP
Process the job,
LOOP
-----
What I need to do is
While the job is in process get the next job so that I can save the time used up for redis blpop .. how can I do this


FishMonger
Veteran / Moderator

Apr 1, 2014, 6:23 AM


Views: 22379
Re: [rprasad] Non blocking IO in perl

Take a look at Proc::Background.
http://search.cpan.org/~bzajac/Proc-Background-1.10/lib/Proc/Background.pm


rprasad
New User

Apr 1, 2014, 11:22 PM


Views: 22374
Re: [FishMonger] Non blocking IO in perl

Creating a new "proc" for every job will be a waste.
My system has to execute 300k jobs every hour.


FishMonger
Veteran / Moderator

Apr 2, 2014, 6:11 AM


Views: 22274
Re: [rprasad] Non blocking IO in perl

Your question was asking how to run multiple jobs at the same time which is what Proc::Background is used for, but if you want more control over that process, take a look at Parallel::ForkManager.

http://search.cpan.org/~szabgab/Parallel-ForkManager-1.06/lib/Parallel/ForkManager.pm

If that doesn't do what you want, then you'll need to give a better explanation of what you are trying to accomplish and you may need to post a short but complete script which demonstrates your issue.