From 1441814c61cc413462b4884281d7519b6af4422f Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 23 Jan 2025 02:17:59 +0100 Subject: [PATCH] doc fixed and one silly error also fixed --- chatsky/context_storages/database.py | 6 ++++-- chatsky/core/pipeline.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chatsky/context_storages/database.py b/chatsky/context_storages/database.py index 3fe0329eb..6e121b8f0 100644 --- a/chatsky/context_storages/database.py +++ b/chatsky/context_storages/database.py @@ -95,8 +95,10 @@ def _lock(function: Callable[..., Awaitable[Any]]): @wraps(function) async def wrapped(self: DBContextStorage, *args, **kwargs): if not self.connected: - logger.warning("Initializing ContextStorage in-place, that is NOT thread-safe, dangerous and in general should be avoided!") - self.connect() + logger.warning( + "Initializing ContextStorage in-place, that is NOT thread-safe and in general should be avoided!" + ) + await self.connect() if not self.is_concurrent: async with self._sync_lock: return await function(self, *args, **kwargs) diff --git a/chatsky/core/pipeline.py b/chatsky/core/pipeline.py index c4a8b8eeb..53f116ff0 100644 --- a/chatsky/core/pipeline.py +++ b/chatsky/core/pipeline.py @@ -269,6 +269,7 @@ async def _run_pipeline( def run(self): """ Method that starts a pipeline and connects to :py:attr:`messenger_interface`. + It also connects to the :py:attr:`context_storage` (if it's not already connected). It passes :py:meth:`_run_pipeline` to :py:attr:`messenger_interface` as a callback, so every time user request is received, :py:meth:`_run_pipeline` will be called. @@ -288,6 +289,7 @@ def __call__( Method that executes pipeline once. Basically, it is a shortcut for :py:meth:`_run_pipeline`. NB! When pipeline is executed this way, :py:attr:`messenger_interface` won't be initiated nor connected. + Still, it connects to the :py:attr:`context_storage` (if it's not already connected) to avoid sync issues. This method has the same signature as :py:class:`~chatsky.core.service.types.PipelineRunnerFunction`. """