diff --git a/lbry/stream/stream_manager.py b/lbry/stream/stream_manager.py index cc4684976..a9ce211e6 100644 --- a/lbry/stream/stream_manager.py +++ b/lbry/stream/stream_manager.py @@ -215,7 +215,7 @@ class StreamManager(SourceManager): server, port = random.choice(self.config.reflector_servers) if stream.sd_hash in self.running_reflector_uploads: return self.running_reflector_uploads[stream.sd_hash] - task = self.loop.create_task(stream.upload_to_reflector(server, port)) + task = self.loop.create_task(self._retriable_reflect_stream(stream, server, port)) self.running_reflector_uploads[stream.sd_hash] = task task.add_done_callback( lambda _: None if stream.sd_hash not in self.running_reflector_uploads else @@ -223,6 +223,12 @@ class StreamManager(SourceManager): ) return task + async def _retriable_reflect_stream(self, stream, host, port): + sent = await stream.upload_to_reflector(host, port) + while not stream.is_fully_reflected and stream.reflector_progress > 0 and len(sent) > 0: + stream.reflector_progress = 0 + sent = await stream.upload_to_reflector(host, port) + async def create(self, file_path: str, key: Optional[bytes] = None, iv_generator: Optional[typing.Generator[bytes, None, None]] = None) -> ManagedStream: descriptor = await StreamDescriptor.create_stream(