Skip to content Skip to sidebar Skip to footer

Python Multiprocess Non-blocking Intercommunication Using Pipes

Is it possible to receive process intercommunications using Pipes in a non-blocking fashion? Consider the following code: from multiprocessing import Process, Pipe import time def

Solution 1:

Use the poll function. Change your while loop like this:

 while True:
       print('Test')
       if parent_conn.poll():
           msg = parent_conn.recv()
           if msg == 'Done':
              break
       else:
           do_something_else()

Solution 2:

According to multiprocessing.Pipe() and multiprocessing.Connection docs, a Connection has the poll() method for that.


Post a Comment for "Python Multiprocess Non-blocking Intercommunication Using Pipes"