Commit feb18cbb authored by Yannick's avatar Yannick
Browse files

async.lock around update cache

parent f10ab48a
Pipeline #45019 passed with stage
in 2 minutes and 21 seconds
......@@ -2,7 +2,6 @@ import logging
from typing import Optional
from datetime import datetime
from osdu_az import conf
from osdu_az.identity.az_identity import AzureIdentity
import logging
from os import environ
import asyncio
from osdu_az.opendes.fake_partition_client import FakePartitionClient
from osdu_az.opendes.partition_client import PartitionClient
from osdu_az.partition.partition_info import PartitionInfo
......@@ -26,11 +26,15 @@ PARTITION_ID = 'id'
class PartitionService:
partition_client = None
scope = ''
partition_cache_lock = asyncio.Lock()
async def get_partition(data_partition_id: str) -> PartitionInfo:
partition_info = PartitionsCache.get(data_partition_id)
if not partition_info:
if partition_info is None:
async with PartitionService.partition_cache_lock:
partition_info = PartitionsCache.get(data_partition_id)
if partition_info is None:
partition_info = await PartitionService._partition_client().get_partition(data_partition_id)
if partition_info:'PartitionService fetching partition info for "{data_partition_id}"')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment