Dev HelpersOpen library
← Back

Rotate waiting jobs through a round-robin queue

Rotate waiting jobs through a round-robin queue in Python.

Open this example in the interactive library

Source code

from collections import deque
jobs = deque(['email', 'index', 'report'])
for _ in range(5):
    print(jobs[0])
    jobs.rotate(-1)

Sample output

email
index
report
email
index