Cola circular en beanstalkd

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.

preguntado el 22 de mayo de 12 a las 15:05

2 Respuestas

I think this could be a solution:

productor:

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

Consumidor:

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

contestado el 22 de mayo de 12 a las 19:05

Yes this something I was considering doing. But how do you stop a recurring job from running anymore. Say I have to crunch numbers every 10 minutes, but the user decides to leave. How would you remove the job from the queue? - Gofres calientes

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.

contestado el 22 de mayo de 12 a las 22:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.