Python Forum

Full Version: multiprocessing Pipe.poll very slow
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I reduced the cpu usage of my program by more than half by using select.poll rather than the Pipe's own poll routine:

in __init__
...
        self.pollin = select.poll()
        self.pollin.register(self.pipe, select.POLLIN)
...


    def readline(self):
#        if self.pipe.poll():   # pipe poll is really slow!!!!!  better use our own                                             
        if self.pollin.poll(0):
            return self.pipe.recv()
        return False
I measured the time from before and after calling pipe.poll and it's more than 10 times slower than using the select poll routine but does exactly the same thing from what I can tell except I have to pass 0 to avoid blocking.


Where is the actual implementation? So why would this be so slow?