Skip to content

Commit

Permalink
Added concurrency lock on get_compute_key_info
Browse files Browse the repository at this point in the history
Removed prints
  • Loading branch information
sveinugu committed Jul 11, 2023
1 parent bc8cf56 commit c938fb9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/crypt4gh_recryptor_service/compute.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from typing import Annotated

from crypt4gh_recryptor_service.app import app, common_info
Expand All @@ -18,6 +19,9 @@ async def get_compute_key_info(
params: ComputeKeyInfoParams,
settings: Annotated[ComputeSettings, Depends(get_compute_settings)],
) -> ComputeKeyInfoResponse:
lock = asyncio.Lock()
await lock.acquire()

user_public_key_file = HashedStrFile(
settings.user_keys_dir, params.crypt4gh_user_public_key, write_to_storage=True)
compute_public_key_file = ComputeKeyFile(
Expand Down Expand Up @@ -52,10 +56,10 @@ async def get_compute_key_info(
compute_public_key_file.read_from_storage()
compute_private_key_file.read_from_storage()

print(compute_public_key_file.key_id)
print(compute_private_key_file.key_id)
assert compute_public_key_file.key_id == compute_private_key_file.key_id

lock.release()

return ComputeKeyInfoResponse(
crypt4gh_compute_public_key=compute_public_key_file.contents,
crypt4gh_compute_keypair_id=compute_public_key_file.key_id,
Expand Down

0 comments on commit c938fb9

Please sign in to comment.