diff --git a/CHANGES/263.feature b/CHANGES/263.feature new file mode 100644 index 000000000..03cec7112 --- /dev/null +++ b/CHANGES/263.feature @@ -0,0 +1 @@ +Artifact chunks are now uploaded in parallel diff --git a/pulpcore/cli/core/context.py b/pulpcore/cli/core/context.py index ad1d76be7..150e98491 100644 --- a/pulpcore/cli/core/context.py +++ b/pulpcore/cli/core/context.py @@ -74,20 +74,24 @@ def upload(self, file: IO[bytes], chunk_size: int = 1000000) -> Any: upload_href = upload_ctx.create(body={"size": size})["pulp_href"] try: + tasks = [] while start < size: end = min(size, start + chunk_size) - 1 file.seek(start) chunk = file.read(chunk_size) range_header = f"bytes {start}-{end}/{size}" - upload_ctx.update( + tasks.append(upload_ctx.update( href=upload_href, parameters={"Content-Range": range_header}, body={"sha256": hashlib.sha256(chunk).hexdigest()}, uploads={"file": chunk}, - ) + non_blocking=True, + )) start += chunk_size - click.echo(".", nl=False, err=True) + for task in tasks: + self.wait_for_task(task) + click.echo(".", nl=False, err=True) click.echo("Upload complete. Creating artifact.", err=True) task = upload_ctx.commit( upload_href,