Skip to content
Merged
Show file tree
Hide file tree
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
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from threading import Lock
from asyncio import Lock
from typing import TypeVar

from ._type_aliases import JSON
Expand All @@ -26,7 +26,7 @@ async def read(
raise ValueError("Storage.read(): target_cls cannot be None.")

result: dict[str, StoreItem] = {}
with self._lock:
async with self._lock:
for key in keys:
if key == "":
raise ValueError("MemoryStorage.read(): key cannot be empty")
Expand All @@ -48,7 +48,7 @@ async def write(self, changes: dict[str, StoreItem]):
if not changes:
raise ValueError("MemoryStorage.write(): changes cannot be None")

with self._lock:
async with self._lock:
for key in changes:
if key == "":
raise ValueError("MemoryStorage.write(): key cannot be empty")
Expand All @@ -58,7 +58,7 @@ async def delete(self, keys: list[str]):
if not keys:
raise ValueError("Storage.delete(): Keys are required when deleting.")

with self._lock:
async with self._lock:
for key in keys:
if key == "":
raise ValueError("MemoryStorage.delete(): key cannot be empty")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from threading import Lock
from asyncio import Lock
Comment thread
rodrigobr-msft marked this conversation as resolved.
from datetime import datetime, timezone
from .transcript_logger import TranscriptLogger, PagedResult
from .transcript_info import TranscriptInfo
Expand All @@ -12,7 +12,7 @@ class TranscriptMemoryStore(TranscriptLogger):
"""
An in-memory implementation of the TranscriptLogger for storing and retrieving activities.

This class is thread-safe and stores all activities in a list. It supports logging activities,
This class is async-safe and stores all activities in a list. It supports logging activities,
Comment thread
rodrigobr-msft marked this conversation as resolved.
retrieving activities for a specific channel and conversation, and filtering by timestamp.
Comment thread
rodrigobr-msft marked this conversation as resolved.
Comment on lines +15 to 16
Activities with a None timestamp are treated as the earliest possible datetime.

Expand Down Expand Up @@ -42,7 +42,7 @@ async def log_activity(self, activity: Activity) -> None:
if not activity.conversation.id:
raise ValueError("Activity.Conversation.id cannot be None")

with self.lock:
async with self.lock:
self._transcript.append(activity)

async def get_transcript_activities(
Expand All @@ -67,7 +67,7 @@ async def get_transcript_activities(
if not conversation_id:
raise ValueError("conversation_id cannot be None")

with self.lock:
async with self.lock:
# Get the activities that match on channel and conversation id
relevant_activities = [
a
Expand Down Expand Up @@ -114,7 +114,7 @@ async def delete_transcript(self, channel_id: str, conversation_id: str) -> None
if not conversation_id:
raise ValueError("conversation_id cannot be None")

with self.lock:
async with self.lock:
self._transcript = [
a
for a in self._transcript
Expand All @@ -139,7 +139,7 @@ async def list_transcripts(
if not channel_id:
raise ValueError("channel_id cannot be None")

with self.lock:
async with self.lock:
relevant_activities = [
a for a in self._transcript if a.channel_id == channel_id
]
Expand Down
Loading