How Do You Use Python’s `multiprocessing.Queue` for Inter-Process Communication?

·

`multiprocessing.Queue` allows safe exchange of data between processes. It supports inter-process communication.

Example:

from multiprocessing import Process, Queue

def worker(queue):
    queue.put('Hello from process')

queue = Queue()
process = Process(target=worker, args=(queue,))
process.start()
process.join()

print(queue.get())

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *