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:

whileTrue:
       print('Test')
       if parent_conn.poll():
           msg = parent_conn.recv()
           if msg == 'Done':
              breakelse:
           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"