altdesktop / python-dbus-next

🚌 The next great DBus library for Python with asyncio support
https://python-dbus-next.readthedocs.io/en/latest/
MIT License
191 stars 60 forks source link

message_bus's socket not closed when disconnect #112

Open yzm157 opened 2 years ago

yzm157 commented 2 years ago

I get a resourcewarning problem, the message_bus's socket not closed when called disconnect. Now, I add two lines in disconnect function, please check it. @acrisci

def disconnect(self):
        """Disconnect the message bus by closing the underlying connection asynchronously.
        All pending  and future calls will error with a connection error.
        """
        self._user_disconnect = True
        try:
            self._sock.shutdown(socket.SHUT_RDWR)
        except Exception:
            logging.warning('could not shut down socket', exc_info=True)
        else:
             self._sock.close()