Reputation: 2254
How do I make my worker ask for more time to work on the job ?
I am using the pheanstalk library. Work is a parsing of a file which depending on the file may take more than 60 secs, the default ttr.
while( $job = $pheanstalk->watch($tubeName)->reserve() ){
// get the job body
$parserExec = unserialize( $job->getData() );
// execute parser - will take more than 1 min most of the time
exec( $parserExec['command'] );
// rest of the stuff - delete job etc
}
I am new to queue stuff and I have been going through the examples I found online. If I am doing this wrong, please do tell. I tried to get the jobstats and write a conditional based on the time-left value but I could not get it to work. When I use the jobStats function in pheanstalk the result is a private object array. What I want is to have the script wait till the exec is complete however long that may take.
Upvotes: 2
Views: 1007
Reputation: 612
You have two options to extend the time to work on a job. The first option is to set your own TTR value when the job is inserted into the queue. The default is 1 minute but you can set that to whatever you need it to be. This is probably your best option. Assuming you use pheanstalk to create the job you can do
$pheanstalk->putInTube(tube, data, priority, delay, ttr)
or
$pheanstalk->put(data, priority, delay, ttr);
You can call $pheanstalk->touch($job)
which will reset the count down on your TTR but you will still be you will still be limited to the the set TTR value which in your case is 1 minute.
Upvotes: 3