X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=blobdiff_plain;f=lib%2Fbup%2Fhelpers.py;h=28d1c6d3595b612f17cfb14decadb0279ee4b8b9;hp=fdc683bd7c2ca739699e760a0b1eda5c3a8f156d;hb=d75a9b7fafc1ff95b91b9ee5f38153e767144d1a;hpb=0dc1dbaabb0edc9e336e506707446bc4dbc67b1a diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index fdc683b..28d1c6d 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -459,7 +459,13 @@ class BaseConn: def close(self): self._base_closed = True - while self._read(65536): pass + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, tb): + with pending_raise(exc_value, rethrow=False): + self.close() def __del__(self): assert self._base_closed