(self, handler)
Attach a read handler.

        The interface is exactly as io.read(). The handler is given a number
        of bytes to fetch, and should return a bytes-like object containing up
        to that number of bytes. If there is no more data available, it should
        return None.
Attach a read handler.
Attach a read handler .
def on_read(self, handler):
        """Attach a read handler.

        The interface is exactly as io.read(). The handler is given a number
        of bytes to fetch, and should return a bytes-like object containing up
        to that number of bytes. If there is no more data available, it should
        return None.

        """

        def interface_handler(buf):
            chunk = handler(len(buf))
            if chunk is None:
                return 0

            bytes_read = len(chunk)
            buf[:bytes_read] = chunk

            return bytes_read

        self.signal_connect("read", interface_handler)
def on_read ( self , handler ) : def interface_handler ( buf ) : chunk = handler ( len ( buf ) ) if chunk is None : return 0 bytes_read = len ( chunk ) buf [ : bytes_read ] = chunk return bytes_read self . signal_connect ( "read" , interface_handler )