gemini-code-assist[bot] commented on code in PR #38456:
URL: https://github.com/apache/beam/pull/38456#discussion_r3223519254
##########
sdks/python/apache_beam/utils/multi_process_shared.py:
##########
@@ -391,10 +393,19 @@ def _get_manager(self):
manager = _SingletonRegistrar(
address=(host, int(port)), authkey=AUTH_KEY)
multiprocessing.current_process().authkey = AUTH_KEY
- try:
+
+ @retry.with_exponential_backoff(
+ num_retries=5,
+ initial_delay_secs=0.1,
+ retry_filter=lambda exn: isinstance(
+ exn, (ConnectionError, EOFError)))
+ def connect_manager():
manager.connect()
+
+ try:
+ connect_manager()
self._manager = manager
- except ConnectionError:
+ except (ConnectionError, EOFError):
Review Comment:

The set of retryable exceptions `(ConnectionError, EOFError)` is duplicated
in both the `retry_filter` and the `except` block. Extracting this into a local
variable improves maintainability and ensures that both locations stay in sync
if the list of exceptions needs to be updated in the future.
```suggestion
retryable_exceptions = (ConnectionError, EOFError)
@retry.with_exponential_backoff(
num_retries=5,
initial_delay_secs=0.1,
retry_filter=lambda exn: isinstance(exn,
retryable_exceptions))
def connect_manager():
manager.connect()
try:
connect_manager()
self._manager = manager
except retryable_exceptions:
```
--
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]