Skip to content
Snippets Groups Projects
minion.py 506 B
Newer Older
#!/usr/bin/env python3

import random
import time

from manager import QueueClient
from work import find_prime


class Minion(QueueClient):
    def run(self):
        while True:
            task = self.queue.get()
            start = time.perf_counter()
            print(f'start work on task {task}...')
            result = find_prime(task)
            print(f'Done ! The {task}-th prime number is {result} (found in {time.perf_counter() - start:.3f}s)')


if __name__ == '__main__':
    Minion().run()