[tor-commits] [stem/master] Ignore BrokenPipeError when closing

atagar at torproject.org atagar at torproject.org
Thu Jan 30 22:27:21 UTC 2020


commit fb40101e44a9c9275187050d827f0b0bce7a56b8
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Jan 30 14:21:38 2020 -0800

    Ignore BrokenPipeError when closing
    
    Our jenkins tests our failing pretty routinely with python 3.7. It turns out
    that this is my bad - unlike python 2.x the socket module frequently (but
    inconsistently) raises a BrokenPipeError when closing a file based socket.
    
    Why would anyone care that the socket they're closing isn't working?
    That's... kinda the point. Oh well - ignoring these exceptions.
---
 docs/change_log.rst | 4 ++++
 stem/socket.py      | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index 53706a74..792baaca 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -46,6 +46,10 @@ Unreleased
 The following are only available within Stem's `git repository
 <download.html>`_.
 
+ * **Controller**
+
+  * Socket based control connections often raised BrokenPipeError when closed
+
 .. _version_1.8:
 
 Version 1.8 (December 29th, 2019)
diff --git a/stem/socket.py b/stem/socket.py
index 4ab534b8..5da02a0c 100644
--- a/stem/socket.py
+++ b/stem/socket.py
@@ -207,7 +207,10 @@ class BaseSocket(object):
         self._socket.close()
 
       if self._socket_file:
-        self._socket_file.close()
+        try:
+          self._socket_file.close()
+        except BrokenPipeError:
+          pass
 
       self._socket = None
       self._socket_file = None



More information about the tor-commits mailing list