Somebody needed a job queue in Python: Multiple writers insert
into it in random order, and the jobs are written into the MySQL
table jobs. From the jobs table,
multiple consumers claim jobs in batches of n or
smaller (n=100), and process them. After processing, the
consumers delete the jobs. We need concurrent job generation and
consumption, with proper and efficient locking.
The full source for this example can be seen in mysql-dev-examples
.
Using our usual includes and setup,
from time import sleep
from random import …[Read more]