php - Pheanstalk touch job to ask more time


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.




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.

People are also looking for solutions to the problem: php - How to reset OpenCart 2+ administrative password?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.