Search code examples
pythonmultiprocessinginter-process-communicat

python non blocking recv with pipe between processes?


Seen this line of code but could not find documentation

self.conn.setblocking(0)

The question is, how do you poll a pool of pipes without blocking? Got a parent process that needs to communicate with some unstable child processes and wish to poll and check periodically if they've something to say. Do not wish to block if they decide they need more time before they have something new to say. Will this magically do this?


Solution

  • This is most likely what you were looking at: https://docs.python.org/2/library/socket.html#socket.socket.setblocking

    You don't give much detail so I'm not exactly sure what you are trying to do, but usually when you have a number of sockets that you want to poll, you will use select (see these examples from PyMOTW).