Opened 3 years ago

Closed 3 years ago

#5448 defect closed fixed (fixed)

twisted.protocols.htb.Bucket.drip() returns invalid results

Reported by: gsk Owned by: jesstess
Priority: normal Milestone:
Component: core Keywords:
Cc: jesstess, thijs, gsk Branch: branches/htb-drip-5448
(diff, github, buildbot, log)
Author: gsk Launchpad Bug:

Description

From the api docs (http://twistedmatrix.com/documents/current/api/twisted.protocols.htb.Bucket.html)

The method drip() of the Bucket class
"Returns True if I am now empty."

The current drip() returns True only if the rate is zero (causing the bucket to drain instantaneously). This behavior does not take into account the possibility that a bucket will drain itself over time.

Attached is a patch containing a unit test for this issue and changes to the Bucket class that remedies this issue.

Attachments (1)

bucket.patch (1.8 KB) - added by gsk 3 years ago.
Unit test and patch to Bucket class

Download all attachments as: .zip

Change History (6)

Changed 3 years ago by gsk

Unit test and patch to Bucket class

comment:1 Changed 3 years ago by jesstess

  • Cc jesstess thijs added
  • Owner set to jesstess

comment:2 Changed 3 years ago by jesstess

  • Author set to jesstess
  • Branch set to branches/htb-drip-5448

(In [33448]) Branching to 'htb-drip-5448'

comment:3 Changed 3 years ago by jesstess

(In [33449]) Apply bucket.patch by gsk.

refs #5448

comment:4 Changed 3 years ago by jesstess

  • Author changed from jesstess to gsk
  • Cc gsk added
  • Keywords review removed

Thanks for the bug report and patch, gsk! I've applied your patch with a couple of cosmetic changes so that it conforms to our coding standards. (The code surrounding your changes is quite old and doesn't set a good example :) ) You can see the changes in revision r33450, and read our coding standard here.

Buildbot results look good.

I'll go ahead and merge.

Thanks again for the patch!

comment:5 Changed 3 years ago by jesstess

  • Resolution set to fixed
  • Status changed from new to closed

(In [33452]) Merge htb-drip-5448

Author: gsk
Review: jesstess
Fixes: #5448

Fix twisted.protocols.htb.Bucket.drip to drip and empty properly with
a non-zero drip rate.

Note: See TracTickets for help on using tickets.