gemini-code-assist[bot] commented on code in PR #38423:
URL: https://github.com/apache/beam/pull/38423#discussion_r3211028678


##########
sdks/python/apache_beam/runners/portability/job_server.py:
##########
@@ -94,8 +94,14 @@ def start(self):
   def stop(self):
     with self._lock:
       if self._started:
-        self._job_server.stop()
-        self._started = False
+        try:
+          self._job_server.stop()
+        finally:
+          self._started = False
+          # Unregister the atexit handler to prevent duplicate
+          # registrations when the server is restarted/reused.
+          if hasattr(atexit, 'unregister'):
+            atexit.unregister(self.stop)

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The check `hasattr(atexit, 'unregister')` is unnecessary as Apache Beam 
supports Python 3.8+, and `atexit.unregister` has been available since Python 
3.4. Removing this check simplifies the code and adheres to modern Python 
standards.
   
   ```python
             atexit.unregister(self.stop)
   ```



-- 
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