Expose bounded seed progress for long reconciler experiments
This commit is contained in:
@@ -65,6 +65,7 @@ async def seed(count: int, concurrency: int) -> dict[str, object]:
|
||||
raise SystemExit("нет ни одного чата: сначала make test")
|
||||
ids = [uuid4() for _ in range(count)]
|
||||
pending = iter(ids)
|
||||
completed = 0
|
||||
started = time.monotonic()
|
||||
async with s3_client(
|
||||
endpoint=settings.s3_endpoint,
|
||||
@@ -78,8 +79,12 @@ async def seed(count: int, concurrency: int) -> dict[str, object]:
|
||||
storage = S3ObjectStorage(client, settings.s3_bucket)
|
||||
|
||||
async def worker() -> None:
|
||||
nonlocal completed
|
||||
for attachment_id in pending:
|
||||
await storage.put(f"attachments/{attachment_id}", body, "image/png")
|
||||
completed += 1
|
||||
if completed % 10000 == 0 or completed == count:
|
||||
print(json.dumps({"progress": completed, "target": count}), flush=True)
|
||||
|
||||
await asyncio.gather(*(worker() for _ in range(concurrency)))
|
||||
stored = time.monotonic()
|
||||
|
||||
Reference in New Issue
Block a user