forked from LBRYCommunity/lbry-sdk
write decrypted blob data from run_in_executor
This commit is contained in:
parent
c9be79f062
commit
e2c123456b
1 changed files with 6 additions and 2 deletions
|
@ -338,6 +338,11 @@ class ManagedStream:
|
||||||
if not self.streaming_responses:
|
if not self.streaming_responses:
|
||||||
self.streaming.clear()
|
self.streaming.clear()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _write_decrypted_blob(handle: typing.IO, data: bytes):
|
||||||
|
handle.write(data)
|
||||||
|
handle.flush()
|
||||||
|
|
||||||
async def _save_file(self, output_path: str):
|
async def _save_file(self, output_path: str):
|
||||||
log.info("save file for lbry://%s#%s (sd hash %s...) -> %s", self.claim_name, self.claim_id, self.sd_hash[:6],
|
log.info("save file for lbry://%s#%s (sd hash %s...) -> %s", self.claim_name, self.claim_id, self.sd_hash[:6],
|
||||||
output_path)
|
output_path)
|
||||||
|
@ -348,8 +353,7 @@ class ManagedStream:
|
||||||
with open(output_path, 'wb') as file_write_handle:
|
with open(output_path, 'wb') as file_write_handle:
|
||||||
async for blob_info, decrypted in self._aiter_read_stream(connection_id=1):
|
async for blob_info, decrypted in self._aiter_read_stream(connection_id=1):
|
||||||
log.info("write blob %i/%i", blob_info.blob_num + 1, len(self.descriptor.blobs) - 1)
|
log.info("write blob %i/%i", blob_info.blob_num + 1, len(self.descriptor.blobs) - 1)
|
||||||
file_write_handle.write(decrypted)
|
await self.loop.run_in_executor(None, self._write_decrypted_blob, file_write_handle, decrypted)
|
||||||
file_write_handle.flush()
|
|
||||||
self.written_bytes += len(decrypted)
|
self.written_bytes += len(decrypted)
|
||||||
if not self.started_writing.is_set():
|
if not self.started_writing.is_set():
|
||||||
self.started_writing.set()
|
self.started_writing.set()
|
||||||
|
|
Loading…
Reference in a new issue