From d7bfeae6b8346efa49c00dd19395e20a3e28404c Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 21 Feb 2018 16:37:00 -0500 Subject: [PATCH] fix position of stream terminator blob --- lbrynet/cryptstream/CryptStreamCreator.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lbrynet/cryptstream/CryptStreamCreator.py b/lbrynet/cryptstream/CryptStreamCreator.py index e9a380ed7..e39a50c1d 100644 --- a/lbrynet/cryptstream/CryptStreamCreator.py +++ b/lbrynet/cryptstream/CryptStreamCreator.py @@ -86,10 +86,9 @@ class CryptStreamCreator(object): self.stopped = True if self.current_blob is not None: self._close_current_blob() - self._finalize() - dl = defer.DeferredList(self.finished_deferreds) - dl.addCallback(lambda _: self._finished()) - return dl + d = self._finalize() + d.addCallback(lambda _: self._finished()) + return d # TODO: move the stream creation process to its own thread and # remove the reactor from this process. @@ -112,6 +111,7 @@ class CryptStreamCreator(object): return defer.succeed(True) + @defer.inlineCallbacks def _finalize(self): """ Finalize a stream by adding an empty @@ -119,14 +119,14 @@ class CryptStreamCreator(object): the stream has ended. This empty blob is not saved to the blob manager """ - log.debug("_finalize has been called") + + yield defer.DeferredList(self.finished_deferreds) self.blob_count += 1 iv = self.iv_generator.next() - final_blob_creator = self.blob_manager.get_blob_creator() - final_blob = self._get_blob_maker(iv, final_blob_creator) - d = final_blob.close() - d.addCallback(self._blob_finished) - self.finished_deferreds.append(d) + final_blob = self._get_blob_maker(iv, self.blob_manager.get_blob_creator()) + stream_terminator = yield final_blob.close() + terminator_info = yield self._blob_finished(stream_terminator) + defer.returnValue(terminator_info) def _write(self, data): while len(data) > 0: