Ticket #601: ticket-601-ratelimit-non-streaming-producer.patch

File ticket-601-ratelimit-non-streaming-producer.patch, 1.6 KB (added by JohnDoeee, 8 years ago)
  • twisted/protocols/policies.py

     
    217217        self.transport.resumeProducing()
    218218
    219219    def throttleWrites(self):
    220         if hasattr(self, "producer"):
    221             self.producer.pauseProducing()
     220        if hasattr(self, "producer") and self.producer is not None:
     221            self.transport.producerPaused = 1
     222            if hasattr(self.producer, 'pauseProducing'):
     223                self.producer.pauseProducing()
    222224
    223225    def unthrottleWrites(self):
    224         if hasattr(self, "producer"):
     226        if hasattr(self, "producer") and self.producer is not None:
     227            self.transport.producerPaused = 0
    225228            self.producer.resumeProducing()
    226229
    227230
  • twisted/internet/abstract.py

     
    252252            self.stopWriting()
    253253            # If I've got a producer who is supposed to supply me with data,
    254254            if self.producer is not None and ((not self.streamingProducer)
    255                                               or self.producerPaused):
     255                                              and not self.producerPaused
     256                                              or self.streamingProducer
     257                                              and self.producerPaused):
    256258                # tell them to supply some more.
    257259                self.producerPaused = 0
    258260                self.producer.resumeProducing()