Implement one queue consumer before building a full worker pool.

Prototype: make_queue(values) returns a new unbounded queue.Queue containing every value in input order. It must not modify the input list. Empty input creates an empty queue.

Final: square_worker(jobs, results) repeatedly calls jobs.get(). An integer job produces its square via results.put(square). The reserved sentinel None ends the worker without producing a result. Call jobs.task_done() exactly once for every retrieved item, including the sentinel, and return None after it. Items following the sentinel remain in jobs. Use a finally block so a failing results.put still acknowledges its job; propagate that exception to the worker's caller. Inputs otherwise do not raise. Example jobs 2, -3, None produce 4, 9. The tests invoke the worker directly for contracts and in a real native thread for integration; use no polling or sleeps.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
Run this exercise with local Python.

This exercise starts native threads or processes, which browser Python does not support. Download your code and tests, then run the command below.

python3 main.py