Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdks/python/apache_beam/io/requestresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ def process(self, request: RequestT, *args, **kwargs):
response = self._repeater.repeat(
self._caller, request, self._timeout, self._metrics_collector)
self._metrics_collector.responses.inc(1)
self._throttler.throttler.successful_request(req_time * MSEC_TO_SEC)
if self._throttler:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to PEP 8, comparisons to singletons like None should always be done with is or is not, never the equality operators or implicit boolean evaluation when checking if an optional argument/attribute is set. Using is not None is safer and more explicit.

Suggested change
if self._throttler:
if self._throttler is not None:
References
  1. PEP 8: Use 'is not None' when testing whether a variable or argument that defaults to None was set to some other value. (link)

self._throttler.throttler.successful_request(req_time * MSEC_TO_SEC)
yield response
except Exception as e:
raise e
Expand Down
Loading