def METHOD_NAME(self, buf):
    size = len(buf)
    self.received += size
    self.fh.write(buf)
    if self.bucket:
        time.sleep(self.bucket.consumed(size))
    else:
        # Avoid small buffers, increasing sleep time slowly if buffer size gets smaller
        # otherwise reduce sleep time percentequal (values are based on tests)
        # So in general cpu time is saved without reducing bandwidth too much
        if size < self.last_recv_size:
            self.sleep += 0.002
        else:
            self.sleep *= 0.7
        self.last_recv_size = size
        time.sleep(self.sleep)