pitrou commented on code in PR #14729:
URL: https://github.com/apache/arrow/pull/14729#discussion_r1033548908


##########
python/pyarrow/conftest.py:
##########
@@ -265,3 +267,19 @@ def add_fs(doctest_namespace, request, tmp_path):
         doctest_namespace["local_path"] = str(tmp_path)
         doctest_namespace["path"] = str(path)
     yield
+
+
[email protected](autouse=True)
+def _close_socket(monkeypatch):
+    """
+    There are occasions when a PytestUnraisableExceptionWarning is
+    raised from pyx files or other __del__ impls that doesn't properly
+    call the initial caller's .close when creating sockets. Here we'll
+    ensure sockets are closed.
+    """
+    class socket_(socket.socket):
+        def __del__(self):
+            if not self._closed:
+                self.close()

Review Comment:
   We definitely don't want to monkeypatch a core type just to avoid some 
warnings.
   
   If some of our routines fail to close a socket we should try to improve 
them. Otherwise we should just live with the warnings, or silence them 
selectively.



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