[text] uppa

Viewer

  1. import multiprocessing
  2.  
  3. def subscriber(queue):
  4.     while True:
  5.         if not queue.empty():
  6.             message = queue.get()
  7.             print(f"Received: {message}")
  8.         else:
  9.             time.sleep(0.1)  # Polling interval
  10.  
  11. if __name__ == '__main__':
  12.     queue = multiprocessing.Queue()
  13.     subscriber_process = multiprocessing.Process(target=subscriber, args=(queue,))
  14.     subscriber_process.start()
  15.     subscriber_process.join()
  16.  

Editor

You can edit this paste and save as new:


File Description
  • uppa
  • Paste Code
  • 03 Jul-2024
  • 454 Bytes
You can Share it: