Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT License.

from typing import TypeVar, Union
from threading import Lock
import asyncio

from azure.cosmos import (
documents,
Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(self, config: CosmosDBStorageConfig):
self._container: ContainerProxy = None
self._compatability_mode_partition_key: bool = False
# Lock used for synchronizing container creation
self._lock: Lock = Lock()
self._lock: asyncio.Lock = asyncio.Lock()

def _create_client(self) -> CosmosClient:
if self._config.url:
Expand Down Expand Up @@ -164,8 +164,8 @@ async def _create_container(self) -> None:

async def initialize(self) -> None:
if not self._container:
with self._lock:
# in case another thread attempted to initialize just before acquiring the lock
async with self._lock:
# in case another async task attempted to initialize just before acquiring the lock
if self._container:
return

Expand Down