Skip to content
Snippets Groups Projects
boss.py 405 B
Newer Older
Guilhem Saurel's avatar
Guilhem Saurel committed
#!/usr/bin/env python3
Guilhem Saurel's avatar
Guilhem Saurel committed

import random
import time

from manager import QueueClient


Guilhem Saurel's avatar
Guilhem Saurel committed
class Boss(QueueClient):
Guilhem Saurel's avatar
Guilhem Saurel committed
    def run(self):
        while True:
Guilhem Saurel's avatar
Guilhem Saurel committed
            task = random.randint(5, 1e4)
Guilhem Saurel's avatar
Guilhem Saurel committed
            print("new task:", task)
Guilhem Saurel's avatar
Guilhem Saurel committed
            self.queue.put(task)
Guilhem Saurel's avatar
Guilhem Saurel committed
            print("tasks left:", self.queue.qsize())
Guilhem Saurel's avatar
Guilhem Saurel committed
            time.sleep(random.randint(1, 2))
Guilhem Saurel's avatar
Guilhem Saurel committed


Guilhem Saurel's avatar
Guilhem Saurel committed
if __name__ == "__main__":
Guilhem Saurel's avatar
Guilhem Saurel committed
    Boss().run()