Skip to content

Commit

Permalink
explicit connect made mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jan 23, 2025
1 parent 28e2d25 commit b5eb543
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chatsky/context_storages/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _lock(function: Callable[..., Awaitable[Any]]):
@wraps(function)
async def wrapped(self: DBContextStorage, *args, **kwargs):
if not self.connected:
await self.connect()
raise RuntimeError("ContextStorage has to be connected before it can be used!")
if not self.is_concurrent:
async with self._sync_lock:
return await function(self, *args, **kwargs)
Expand Down
2 changes: 2 additions & 0 deletions chatsky/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,6 @@ def __call__(
This method has the same signature as :py:class:`~chatsky.core.service.types.PipelineRunnerFunction`.
"""
if not self.context_storage.connected:
asyncio.run(self.context_storage.connect())
return asyncio.run(self._run_pipeline(request, ctx_id, update_ctx_misc))
1 change: 1 addition & 0 deletions tests/context_storages/test_dbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ async def db(self, db_kwargs, db_teardown, tmpdir_factory):
kwargs["__testing_file__"] = str(tmpdir_factory.mktemp("data").join("file.db"))
db_kwargs["path"] = db_kwargs["path"].format(**kwargs)
context_storage = context_storage_factory(**db_kwargs)
await context_storage.connect()

yield context_storage

Expand Down

0 comments on commit b5eb543

Please sign in to comment.