def write(self, data): if self.throttle: ThrottlingProtocol.write(self, data) if self.stats: self.stats.sentBytes(len(data)) else: ProtocolWrapper.write(self, data)
def writeSequence(self, seq): if self.throttle: ThrottlingProtocol.writeSequence(self, seq) if self.stats: self.stats.sentBytes(reduce(operator.add, map(len, seq))) else: ProtocolWrapper.writeSequence(self, seq)
def registerProducer(self, producer, streaming): ThrottlingProtocol.registerProducer(self, producer, streaming) streamType = getattr(producer, 'stream', None) if isinstance(streamType, UploadStream): self.throttle = True
def __init__(self, factory, wrappedProtocol): ThrottlingProtocol.__init__(self, factory, wrappedProtocol) self.throttle = False