def METHOD_NAME(self, buffer_class):
    r, w = self.pipe()
    # set nbytes such that for sure it is > maximum pipe buffer
    nbytes = 1000000
    block = b'x' * 4096
    buf = buffer_class(block)
    # Lack of "nonlocal" keyword in Python 2.x:
    bytesread = [0]
    byteswritten = [0]
    def produce():
        while byteswritten[0] != nbytes:
            bytesleft = nbytes - byteswritten[0]
            byteswritten[0] += self.write(w, buf[:min(bytesleft, 4096)])
    def consume():
        while bytesread[0] != nbytes:
            bytesleft = nbytes - bytesread[0]
            bytesread[0] += len(self.read(r, min(bytesleft, 4096)))
    producer = Greenlet(produce)
    producer.start()
    consumer = Greenlet(consume)
    consumer.start_later(1)
    # If patching was not succesful, the producer will have filled
    # the pipe before the consumer starts, and would block the entire
    # process. Therefore the next line would never finish.
    joinall([producer, consumer])
    self.assertEqual(bytesread[0], nbytes)
    self.assertEqual(bytesread[0], byteswritten[0])