-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
Description
I'm looking at this 2 files:
- https://github.com/GoogleCloudPlatform/google-cloud-python/blob/5c010e3790c9067e6d7bf8ba37724ee5121eadb7/pubsub/google/cloud/pubsub_v1/subscriber/policy/base.py#L215
- https://github.com/GoogleCloudPlatform/google-cloud-python/blob/5c010e3790c9067e6d7bf8ba37724ee5121eadb7/pubsub/tests/unit/pubsub_v1/subscriber/test_policy_base.py
Should the code in base.py line 215 be max instead of min?
self._bytes = min([self._bytes, 0])
Current code:
- current state
self._bytes = 50 - then we call
self._bytes -= 20 - now
self._bytes == 30 - but then we do
self._bytes = min([30, 0])->self._bytes = 0
Should be:
- current state
self._bytes = 50 - then we call
self._bytes -= 20 - now
self._bytes == 30 - but then we do
self._bytes = max([30, 0])->self._bytes = 30
even if we drop it below 0, we should use max:
self._bytes = 10self._bytes -= 20self._bytes == -10min([-10, 0]) == -10should bemax([-10, 0]) == 0
Or is there something I miss?
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.