diff --git a/lbrynet/blob/reader.py b/lbrynet/blob/reader.py index dd248c8fd..4d1f51dff 100644 --- a/lbrynet/blob/reader.py +++ b/lbrynet/blob/reader.py @@ -40,11 +40,15 @@ class HashBlobReader(object): read(size) and close() """ def __init__(self, file_path, finished_cb): + self.file_path = file_path self.finished_cb = finished_cb self.finished_cb_d = None - self.read_handle = open(file_path, 'rb') + self.read_handle = open(self.file_path, 'rb') def __del__(self): + if self.finished_cb_d is None: + log.warn("Garbage collection was called, but reader for %s was not closed yet", + self.file_path) self.close() def read(self, size=-1): diff --git a/lbrynet/blob/writer.py b/lbrynet/blob/writer.py index a95430386..dc4d3d77a 100644 --- a/lbrynet/blob/writer.py +++ b/lbrynet/blob/writer.py @@ -16,6 +16,11 @@ class HashBlobWriter(object): self._hashsum = get_lbry_hash_obj() self.len_so_far = 0 + def __del__(self): + if self.finished_cb_d is None: + log.warn("Garbage collection was called, but writer was not closed yet") + self.close() + @property def blob_hash(self): return self._hashsum.hexdigest()