Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: POE to fire off job based on date/time

by rcaputo (Chaplain)
on Feb 16, 2011 at 02:36 UTC ( [id://888437]=note: print w/replies, xml ) Need Help??


in reply to POE to fire off job based on date/time

If the weekly task is relatively isolated, start another POE::Session to do it. Something like this may be sufficient if do_that_thing() doesn't take too long.

POE::Session->create( inline_states => { _start => sub { my $next_unix_time = calculate_when(); $_[KERNEL]->alarm(weekly_task => $next_unix_time); }, weekly_task => { do_that_thing(); my $next_unix_time = calculate_when(); $_[KERNEL]->alarm(weekly_task => $next_unix_time); }, }, );

If do_that_thing() takes too long, then it may need to involve system(1,"command"). See perlport for discussion of system(1,"command") on MSWin32. For best results, use POE::Kernel's sig_child() to detect when the command has ended.

And a word about fork() in POE on Windows. If you plan to do anything more than system(1,"command") in the "subprocess", then you should check out POE's Github repository for pre-release iThread-safety fixes. As you may be aware, fork() on MSWin32 is implemented in terms of iThreads, so modules must be iThread-safe to fork() there.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://888437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found