Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 7bd5ed5

Browse files
authored
Merge pull request #169 from exfinen/update-c
Introduce file-level lock for pem file exchange
2 parents a9dc190 + 26ccfbb commit 7bd5ed5

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

config-docker-compose.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def gen_env_consumer_api(
2222
"""
2323
return output
2424

25-
def gen_env_coord(
25+
def gen_env_coord(
2626
transport: str,
2727
party_hosts: list[str],
2828
party_ports: list[int],

gen-self-signed-cert.sh

-6
This file was deleted.

mpc_demo_infra/computation_party_server/routes.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import asyncio
1010
import os
1111
import glob
12+
from filelock import FileLock
1213

1314
import requests
1415
from fastapi import APIRouter, Depends, HTTPException
@@ -464,7 +465,11 @@ def get_party_cert(host: str, port: int, party_id: int):
464465
logger.error(f"party_id mismatch, expected {party_id}, got {data['party_id']}")
465466
raise HTTPException(status_code=500, detail=f"Party ID mismatch, expected {party_id}, got {data['party_id']}")
466467
logger.info(f"Fetched party cert from {host}:{port}")
467-
(CERTS_PATH / f"P{party_id}.pem").write_text(data["cert_file"])
468+
pem_file = CERTS_PATH / f"P{party_id}.pem"
469+
lock_file = f"{pem_file}.lock"
470+
with FileLock(lock_file):
471+
pem_file.write_text(data["cert_file"])
472+
468473
logger.info(f"Saved party cert to {CERTS_PATH / f'P{party_id}.pem'}")
469474

470475
with ThreadPoolExecutor() as executor:

poetry.lock

+18-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["mhchia <[email protected]>"]
66
readme = "README.md"
77

88
[tool.poetry.dependencies]
9-
python = ">=3.8,<3.14"
9+
python = ">=3.9,<3.14"
1010
fastapi = "^0.95.0"
1111
uvicorn = "^0.22.0"
1212
sqlalchemy = "^1.4.0"
@@ -17,6 +17,7 @@ aiohttp = "^3.10.9"
1717
slowapi = "^0.1.9"
1818
readerwriterlock = "^1.0.9"
1919

20+
filelock = "^3.17.0"
2021
[tool.poetry.group.dev.dependencies]
2122
pytest = "^8.2.0"
2223
pytest-asyncio = "^0.24.0"

0 commit comments

Comments
 (0)