// lesson: channels
Channels
Python has no built-in channel type, but queue.Queue plays the same role:
one thread puts values in, another gets them out, and the queue itself
handles the locking. A None put onto the queue is a common convention for
"no more values" โ a sentinel value the receiving side treats as a close
signal, rather than real data.
import queue
import threading
q = queue.Queue()
threading.Thread(target=lambda: q.put(42)).start()
print(q.get()) # 42
โบ Fan In
15 ptsImplement merge(a, b) where a and b are queue.Queue instances that
will each eventually receive a None sentinel marking end-of-stream. Return
a new queue.Queue that yields every value from both inputs (order between
them doesn't matter) and then yields None once both are exhausted.
Log in to submit a solution and earn points.