tarun-google commented on code in PR #37218:
URL: https://github.com/apache/beam/pull/37218#discussion_r2668933849


##########
sdks/python/apache_beam/ml/inference/base.py:
##########
@@ -431,6 +437,19 @@ def run_inference(
     Returns:
       An Iterable of Predictions.
     """
+    if self._rate_limiter:
+      if self._shared_rate_limiter is None:
+
+        def init_limiter():
+          return self._rate_limiter
+
+        self._shared_rate_limiter = self._shared_handle.acquire(init_limiter)
+
+      if not self._shared_rate_limiter.throttle(hits_added=len(batch)):
+        raise RuntimeError(
+            "Rate Limit Exceeded, "
+            "Could not process this batch.")

Review Comment:
   agreed, i will introduce RateLimitExceeded error type. Now users have change 
to keep spinning on their custom back-off policy or fail fast. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to