Question

I'm using beanstalkc a python wrapper for the beanstalkd application.

What I'd like to do is have the producer to put some jobs(e.g: 'a','b','c','d') once and that the consumer could get the jobs continually(e.g: 'a','b','c','d','a','b',...).

In the consumer I get the jobs with job.reserve(). I thought the solution was just reserving the jobs without deleting them, but after I ran some consumer processes I got a TIMEOUT ERROR.

I'm clearly doing something wrong but I couldn't find a way to "re-queue" the jobs the consumers use.

Was it helpful?

Solution

I think this could be a solution:

producer:

queue.put('a', priority=0)

Consumer:

job = queue.reserve()
do something with job
new_priority = job.stats()['pri'] + 1
job.release(priority=new_priority)

OTHER TIPS

Why not just, when you've completed a particular job, and after you've released it, put another copy of the same job you've just finished back into the queue?

You'd otherwise be trying to get it to do something that it's not designed to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top