add reflector_progress
to file_list
results
This commit is contained in:
parent
3152046173
commit
3ca41be686
3 changed files with 10 additions and 3 deletions
|
@ -108,7 +108,8 @@ def encode_file_doc():
|
||||||
'metadata': '(dict) None if claim is not found else the claim metadata',
|
'metadata': '(dict) None if claim is not found else the claim metadata',
|
||||||
'channel_claim_id': '(str) None if claim is not found or not signed',
|
'channel_claim_id': '(str) None if claim is not found or not signed',
|
||||||
'channel_name': '(str) None if claim is not found or not signed',
|
'channel_name': '(str) None if claim is not found or not signed',
|
||||||
'claim_name': '(str) None if claim is not found else the claim name'
|
'claim_name': '(str) None if claim is not found else the claim name',
|
||||||
|
'reflector_progress': '(int) reflector upload progress, 0 to 100'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -307,7 +308,8 @@ class JSONResponseEncoder(JSONEncoder):
|
||||||
'height': tx_height,
|
'height': tx_height,
|
||||||
'confirmations': (best_height + 1) - tx_height if tx_height > 0 else tx_height,
|
'confirmations': (best_height + 1) - tx_height if tx_height > 0 else tx_height,
|
||||||
'timestamp': self.ledger.headers.estimated_timestamp(tx_height),
|
'timestamp': self.ledger.headers.estimated_timestamp(tx_height),
|
||||||
'is_fully_reflected': managed_stream.is_fully_reflected
|
'is_fully_reflected': managed_stream.is_fully_reflected,
|
||||||
|
'reflector_progress': managed_stream.reflector_progress
|
||||||
}
|
}
|
||||||
|
|
||||||
def encode_claim(self, claim):
|
def encode_claim(self, claim):
|
||||||
|
|
|
@ -65,6 +65,7 @@ class ManagedStream:
|
||||||
'downloader',
|
'downloader',
|
||||||
'analytics_manager',
|
'analytics_manager',
|
||||||
'fully_reflected',
|
'fully_reflected',
|
||||||
|
'reflector_progress',
|
||||||
'file_output_task',
|
'file_output_task',
|
||||||
'delayed_stop_task',
|
'delayed_stop_task',
|
||||||
'streaming_responses',
|
'streaming_responses',
|
||||||
|
@ -101,6 +102,7 @@ class ManagedStream:
|
||||||
self.analytics_manager = analytics_manager
|
self.analytics_manager = analytics_manager
|
||||||
|
|
||||||
self.fully_reflected = asyncio.Event(loop=self.loop)
|
self.fully_reflected = asyncio.Event(loop=self.loop)
|
||||||
|
self.reflector_progress = 0
|
||||||
self.file_output_task: typing.Optional[asyncio.Task] = None
|
self.file_output_task: typing.Optional[asyncio.Task] = None
|
||||||
self.delayed_stop_task: typing.Optional[asyncio.Task] = None
|
self.delayed_stop_task: typing.Optional[asyncio.Task] = None
|
||||||
self.streaming_responses: typing.List[typing.Tuple[Request, StreamResponse]] = []
|
self.streaming_responses: typing.List[typing.Tuple[Request, StreamResponse]] = []
|
||||||
|
@ -445,9 +447,10 @@ class ManagedStream:
|
||||||
]
|
]
|
||||||
log.info("we have %i/%i needed blobs needed by reflector for lbry://%s#%s", len(we_have), len(needed),
|
log.info("we have %i/%i needed blobs needed by reflector for lbry://%s#%s", len(we_have), len(needed),
|
||||||
self.claim_name, self.claim_id)
|
self.claim_name, self.claim_id)
|
||||||
for blob_hash in we_have:
|
for i, blob_hash in enumerate(we_have):
|
||||||
await protocol.send_blob(blob_hash)
|
await protocol.send_blob(blob_hash)
|
||||||
sent.append(blob_hash)
|
sent.append(blob_hash)
|
||||||
|
self.reflector_progress = int((i + 1) / len(we_have) * 100)
|
||||||
except (asyncio.TimeoutError, ValueError):
|
except (asyncio.TimeoutError, ValueError):
|
||||||
return sent
|
return sent
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
|
|
|
@ -46,7 +46,9 @@ class TestStreamAssembler(AsyncioTestCase):
|
||||||
reflector.start_server(5566, '127.0.0.1')
|
reflector.start_server(5566, '127.0.0.1')
|
||||||
await reflector.started_listening.wait()
|
await reflector.started_listening.wait()
|
||||||
self.addCleanup(reflector.stop_server)
|
self.addCleanup(reflector.stop_server)
|
||||||
|
self.assertEqual(0, self.stream.reflector_progress)
|
||||||
sent = await self.stream.upload_to_reflector('127.0.0.1', 5566)
|
sent = await self.stream.upload_to_reflector('127.0.0.1', 5566)
|
||||||
|
self.assertEqual(100, self.stream.reflector_progress)
|
||||||
self.assertSetEqual(
|
self.assertSetEqual(
|
||||||
set(sent),
|
set(sent),
|
||||||
set(map(lambda b: b.blob_hash,
|
set(map(lambda b: b.blob_hash,
|
||||||
|
|
Loading…
Reference in a new issue