From aab43c8d6cc78a83d6e26535bbc3551dd3a14d9c Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Wed, 27 Sep 2017 17:00:51 -0400 Subject: [PATCH] close the reader directly instead of calling close_read_handle() --- lbrynet/core/StreamDescriptor.py | 2 +- lbrynet/core/server/BlobRequestHandler.py | 4 ++-- lbrynet/daemon/Daemon.py | 4 ++-- lbrynet/reflector/client/blob.py | 3 ++- lbrynet/reflector/client/client.py | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lbrynet/core/StreamDescriptor.py b/lbrynet/core/StreamDescriptor.py index b3fb714cb..d0bd28310 100644 --- a/lbrynet/core/StreamDescriptor.py +++ b/lbrynet/core/StreamDescriptor.py @@ -55,7 +55,7 @@ class BlobStreamDescriptorReader(StreamDescriptorReader): f = self.blob.open_for_reading() if f is not None: raw_data = f.read() - self.blob.close_read_handle(f) + f.close() return raw_data else: raise ValueError("Could not open the blob for reading") diff --git a/lbrynet/core/server/BlobRequestHandler.py b/lbrynet/core/server/BlobRequestHandler.py index 308d0c822..e075fe086 100644 --- a/lbrynet/core/server/BlobRequestHandler.py +++ b/lbrynet/core/server/BlobRequestHandler.py @@ -89,7 +89,7 @@ class BlobRequestHandler(object): def cancel_send(self, err): if self.currently_uploading is not None: - self.currently_uploading.close_read_handle(self.read_handle) + self.read_handle.close() self.read_handle = None self.currently_uploading = None return err @@ -225,7 +225,7 @@ class BlobRequestHandler(object): def set_not_uploading(reason=None): if self.currently_uploading is not None: - self.currently_uploading.close_read_handle(self.read_handle) + self.read_handle.close() self.read_handle = None self.currently_uploading = None self.file_sender = None diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index f77f183c0..a56e3d910 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -2375,7 +2375,7 @@ class Daemon(AuthJSONRPCServer): if encoding and encoding in decoders: blob_file = blob.open_for_reading() result = decoders[encoding](blob_file.read()) - blob.close_read_handle(blob_file) + blob_file.close() else: result = "Downloaded blob %s" % blob_hash @@ -2624,7 +2624,7 @@ class Daemon(AuthJSONRPCServer): def read_sd_blob(sd_blob): sd_blob_file = sd_blob.open_for_reading() decoded_sd_blob = json.loads(sd_blob_file.read()) - sd_blob.close_read_handle(sd_blob_file) + sd_blob_file.close() return decoded_sd_blob resolved_result = yield self.session.wallet.resolve(uri) diff --git a/lbrynet/reflector/client/blob.py b/lbrynet/reflector/client/blob.py index 1f1c540a2..d2c41ce30 100644 --- a/lbrynet/reflector/client/blob.py +++ b/lbrynet/reflector/client/blob.py @@ -94,7 +94,7 @@ class BlobReflectorClient(Protocol): def set_not_uploading(self): if self.next_blob_to_send is not None: - self.next_blob_to_send.close_read_handle(self.read_handle) + self.read_handle.close() self.read_handle = None self.next_blob_to_send = None self.file_sender = None @@ -105,6 +105,7 @@ class BlobReflectorClient(Protocol): assert self.read_handle is not None, \ "self.read_handle was None when trying to start the transfer" d = self.file_sender.beginFileTransfer(self.read_handle, self) + d.addCallback(lambda _: self.read_handle.close()) return d def handle_handshake_response(self, response_dict): diff --git a/lbrynet/reflector/client/client.py b/lbrynet/reflector/client/client.py index ebf605b02..660abbd39 100644 --- a/lbrynet/reflector/client/client.py +++ b/lbrynet/reflector/client/client.py @@ -179,7 +179,7 @@ class EncryptedFileReflectorClient(Protocol): def set_not_uploading(self): if self.next_blob_to_send is not None: log.debug("Close %s", self.next_blob_to_send) - self.next_blob_to_send.close_read_handle(self.read_handle) + self.read_handle.close() self.read_handle = None self.next_blob_to_send = None if self.file_sender is not None: