How to subscribe to an event from a process and to address specifically the data process in python 3?

Welcome! Decided to learn Python. Tell me how to subscribe to an event data change in the process?

I tried something like this:
import multiprocessing as mp
import logging
import time

def foo(q):
 i = 1
 while True:
 q.put({'yndx': i})
 i += 1

if __name__ == '__main__':
 q = mp.Queue()
 p = mp.Process(target=foo, args=(q,))
 while True:
 if not q.empty():
 broadcast = q.get()

But then the infinite loop seems useful to the maximum and when they will be a lot of... time.sleep in an infinite loop to use do not want, as you want instant delivery of data.

And in the end the task is that one process receives data, and other processes processors take what they want. However, their number varies during the life of the program.
April 19th 20 at 12:41
1 answer
April 19th 20 at 12:43
Figured out myself. To receive the event that there is new data use multiprocessing.Event()and for the exchange of data multiprocessing.Manager().dict()

Find more questions by tags multithreadingPython