From 80286ea89871ef0313230055c6c80e945b757cac Mon Sep 17 00:00:00 2001 From: Carl Suster Date: Sat, 13 Apr 2019 14:18:31 +1000 Subject: [PATCH] bluelet: catch ECONNRESET When ncmpcpp quits after an error it causes a "connection reset by peer" exception, also known as ECONNRESET (104) in errno terms. In Python 2 this is mapped to a `socket.error` and in Python 3 this is `ConnectionResetError` which is thankfully a subclass of the `socket.error` exception class. --- beets/util/bluelet.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/beets/util/bluelet.py b/beets/util/bluelet.py index 0da17559b..dcc80e041 100644 --- a/beets/util/bluelet.py +++ b/beets/util/bluelet.py @@ -346,6 +346,10 @@ def run(root_coro): exc.args[0] == errno.EPIPE: # Broken pipe. Remote host disconnected. pass + elif isinstance(exc.args, tuple) and \ + exc.args[0] == errno.ECONNRESET: + # Connection was reset by peer. + pass else: traceback.print_exc() # Abort the coroutine.