Closed gonvaled closed 12 years ago
I have investigated the issue a bit, and it seems related to not returning "True" in the process_data function, which prevents the job from being deleted from the tube. The question remains if a burst of DeadlineSoon exception is to be expected in that situation.
Actually, the problem was that I was not deleting the job from the queue: I was receiving a job without data in the body (I do not know why) and my code was not handling properly that case. Now I also delete the jobs which have no data in the body.
The question is anyway still open: why so many DeadlineSoon exceptions, so fast?
Yes, after a quick look at the code you don't delete
a successfully reserved job if the job's body is empty.
So that means you have a job reserved, which you didn't delete, and then loop through to reserve(timeout=1)
to wait for another job to reserve. As soon as the time-to-run of the first job (which you didn't delete) comes close to zero, beanstalkd will signal that by answering each reserve
immediately with a DEADLINE_SOON
reply. As you are not doing anything except outputting a log message in the DEADLINE_SOON
case, you are basically busy-looping over reserve
calls. In other words, you send reserve
s as fast as possible, beanstalkd answers with DEADLINE_SOON
as fast as possible. And this will of course result in a lot of DeadlineSoon
exceptions.
I hope that helps explaining what's going on.
Thanks earl, understood. The only open question that remains is: why am I getting jobs with empty body? I am the only one putting jobs in the tube, and they have definitely data.
In the code snippet above, it's not really the body you are checking, but the result after JSON decoding. Maybe something's wrong in the JSON encoding/decoding.
I get over 6700 exceptions in under a second, and then it works normally again. What exactly happens is as follows (please, see my implementation of BOSS and WORKER below): 1) The boss and the worker connects 2) I put a job in the tube 3) I receive it 4) Some time later, lots of DeadlineSoon exceptions arrive, very fast 5) After ca. 1s, they stop again, and a new job is received (which I never sent) 6) the situation is normal again, for a while, until we find ourselves again in step 4
My implementation is as follows:
This is the output: