Skip to content

Commit dd5b7c1

Browse files
author
xueyulinn
committed
reuse docker client at code_indexing.py
1 parent 92d0554 commit dd5b7c1

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

codehawk/services/code_indexing.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313

1414

1515
async def run_code_indexing(payload: dict[str, Any]) -> None:
16+
docker_client = DockerRunner()
1617
pr_ctx = PullRequestWebhookDTO.from_github_webhook_payload(payload)
17-
await asyncio.to_thread(clone_repo, pr_ctx)
18-
sta_task = asyncio.to_thread(sta_repo, pr_ctx)
19-
chunk_task = asyncio.to_thread(chunk_repo, pr_ctx)
18+
await asyncio.to_thread(clone_repo, docker_client, pr_ctx)
2019

20+
sta_task = asyncio.to_thread(sta_repo, docker_client, pr_ctx)
21+
chunk_task = asyncio.to_thread(chunk_repo, pr_ctx)
2122
await asyncio.gather(sta_task, chunk_task)
2223

2324

24-
def clone_repo(pr_ctx: PullRequestWebhookDTO) -> None:
25-
docker_client = DockerRunner()
25+
def clone_repo(docker_client: DockerRunner, pr_ctx: PullRequestWebhookDTO) -> None:
2626
minio_client = get_minio_storage()
2727
repo_upload_url = minio_client.get_upload_repo_url(
2828
owner=pr_ctx.owner,
@@ -39,8 +39,7 @@ def clone_repo(pr_ctx: PullRequestWebhookDTO) -> None:
3939
f"git fetcher failed: {fetcher_logs.decode(errors='replace')}")
4040

4141

42-
def sta_repo(pr_ctx: PullRequestWebhookDTO) -> None:
43-
docker_client = DockerRunner()
42+
def sta_repo(docker_client: DockerRunner, pr_ctx: PullRequestWebhookDTO) -> None:
4443
minio_client = get_minio_storage()
4544
repo_download_url = minio_client.get_download_repo_url(
4645
owner=pr_ctx.owner,

0 commit comments

Comments
 (0)