damccorm commented on code in PR #40822:
URL: https://github.com/apache/beam/pull/40822#discussion_r4497150661


##########
sdks/python/apache_beam/utils/multi_process_shared.py:
##########
@@ -150,8 +152,22 @@ def release(self, proxy):
   def unsafe_hard_delete(self):
     with self.lock:
       if self.initialied:
+        obj = self.obj
         del self.obj
         self.initialied = False
+        # When hard-deleting in a spawned server process that exits via
+        # os._exit(0), an in-flight RPC thread (e.g. a timed-out call) may
+        # still hold a stack reference to `obj`, preventing CPython from
+        # invoking `obj.__del__()` before `os._exit(0)`.
+        if (self._hard_delete_callback is not None and
+            sys.getrefcount(obj) > 2 and hasattr(type(obj), '__del__')):
+          try:
+            type(obj).__del__(obj)

Review Comment:
   I agree with your concerns here. I think we can just skip this part of the 
PR. This only really matters if there are shared resources that get cleaned up 
beyond the object (e.g. shared file references), the memory itself is 
guaranteed to get reclaimed. This has no implications on RunInference, and I 
think it is a reasonable behavior to not guarantee in an unsafe deletion 
scenario.
   
   I'll get rid of this piece.



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