Skip to content

PubSub: correctly decrement the byte counter in drop() #4516

@aongko

Description

@aongko

I'm looking at this 2 files:

Should the code in base.py line 215 be max instead of min?

self._bytes = min([self._bytes, 0])

Current code:

  1. current state self._bytes = 50
  2. then we call self._bytes -= 20
  3. now self._bytes == 30
  4. but then we do self._bytes = min([30, 0]) -> self._bytes = 0

Should be:

  1. current state self._bytes = 50
  2. then we call self._bytes -= 20
  3. now self._bytes == 30
  4. but then we do self._bytes = max([30, 0]) -> self._bytes = 30

even if we drop it below 0, we should use max:

  1. self._bytes = 10
  2. self._bytes -= 20
  3. self._bytes == -10
  4. min([-10, 0]) == -10 should be max([-10, 0]) == 0

Or is there something I miss?

Metadata

Metadata

Labels

api: pubsubIssues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions