Skip to content

Commit de8ed30

Browse files
author
Tony Crisci
committed
handle message bus errors on disconnect
1 parent 1213667 commit de8ed30

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

dbus_next/message_bus.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,10 @@ def disconnect(self):
369369
All pending and future calls will error with a connection error.
370370
"""
371371
self._user_disconnect = True
372-
self._sock.shutdown(socket.SHUT_RDWR)
372+
try:
373+
self._sock.shutdown(socket.SHUT_RDWR)
374+
except Exception:
375+
logging.warning('could not shut down socket', exc_info=True)
373376

374377
def next_serial(self) -> int:
375378
"""Get the next serial for this bus. This can be used as the ``serial``
@@ -435,7 +438,10 @@ def _finalize(self, err):
435438
self._disconnected = True
436439

437440
for handler in self._method_return_handlers.values():
438-
handler(None, err)
441+
try:
442+
handler(None, err)
443+
except Exception:
444+
logging.warning('a message handler threw an exception on shutdown', exc_info=True)
439445

440446
self._method_return_handlers.clear()
441447

0 commit comments

Comments
 (0)