fireback finished_deferred after deleting from self.writers so that BlobFile state is accurate after finished_deferred is called

This commit is contained in:
Kay Kurokawa 2017-09-12 12:03:49 -04:00 committed by Jack Robison
parent b655cd4fa6
commit f2deee7201
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF

View file

@ -15,7 +15,6 @@ from lbrynet.core.utils import is_valid_blobhash
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class HashBlobReader(object): class HashBlobReader(object):
implements(interfaces.IConsumer) implements(interfaces.IConsumer)
@ -142,8 +141,8 @@ class HashBlob(object):
self._verified = True self._verified = True
for p, (w, finished_deferred) in self.writers.items(): for p, (w, finished_deferred) in self.writers.items():
if w == writer: if w == writer:
finished_deferred.callback(self)
del self.writers[p] del self.writers[p]
finished_deferred.callback(self)
return True return True
log.warning( log.warning(
"Somehow, the writer that was accepted as being valid was already removed: %s", "Somehow, the writer that was accepted as being valid was already removed: %s",
@ -153,8 +152,8 @@ class HashBlob(object):
def errback_finished_deferred(err): def errback_finished_deferred(err):
for p, (w, finished_deferred) in self.writers.items(): for p, (w, finished_deferred) in self.writers.items():
if w == writer: if w == writer:
finished_deferred.errback(err)
del self.writers[p] del self.writers[p]
finished_deferred.errback(err)
def cancel_other_downloads(): def cancel_other_downloads():
for p, (w, finished_deferred) in self.writers.items(): for p, (w, finished_deferred) in self.writers.items():