X-Git-Url: http://git.kaliko.me/?p=python-musicpd.git;a=blobdiff_plain;f=musicpd.py;h=9603edc5baacc4b8ce04028aa3248073a5fa7267;hp=d96e76a54387fcfb7d6ac8db9be83540252edf83;hb=6678aeaaa0b57c4e9d640177b3de560c72d664c9;hpb=40455e48fef4d5ac8bf2c19f745d7495180e7205 diff --git a/musicpd.py b/musicpd.py index d96e76a..9603edc 100644 --- a/musicpd.py +++ b/musicpd.py @@ -1,5 +1,6 @@ # python-musicpd: Python MPD client library # Copyright (C) 2012-2021 kaliko +# Copyright (C) 2021 Wonko der Verständige # Copyright (C) 2019 Naglis Jonaitis # Copyright (C) 2019 Bart Van Loon # Copyright (C) 2008-2010 J. Alexander Treuman @@ -726,6 +727,13 @@ class MPDClient: self._sock.close() self._reset() + def __enter__(self): + self.connect() + return self + + def __exit__(self, exception_type, exception_value, exception_traceback): + self.disconnect() + def fileno(self): """Return the socket’s file descriptor (a small integer). This is useful with :py:obj:`select.select`.