forked from LBRYCommunity/lbry-sdk
close the reader directly instead of calling close_read_handle()
This commit is contained in:
parent
f6da00cbab
commit
aab43c8d6c
5 changed files with 8 additions and 7 deletions
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue