Skip to content

Commit

Permalink
increased default insert timeout (#639)
Browse files Browse the repository at this point in the history
* increased default insert timeout

* lint
  • Loading branch information
bjchambers authored Aug 13, 2024
1 parent 403eef4 commit eb54a9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libs/knowledge-store/ragstack_knowledge_store/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def execute(
query: PreparedStatement,
parameters: tuple[Any, ...] | None = None,
callback: _Callback | None = None,
timeout: float | None = None,
) -> None:
"""Execute a query concurrently.
Expand All @@ -77,6 +78,7 @@ def execute(
query: The query to execute.
parameters: Parameter tuple for the query. Defaults to `None`.
callback: Callback to apply to the results. Defaults to `None`.
timeout: Timeout to use (if not the session default).
"""
# TODO: We could have some form of throttling, where we track the number
# of pending calls and queue things if it exceed some threshold.
Expand All @@ -86,7 +88,14 @@ def execute(
if self._error is not None:
return

future: ResponseFuture = self._session.execute_async(query, parameters)
execute_kwargs = {}
if timeout is not None:
execute_kwargs["timeout"] = timeout
future: ResponseFuture = self._session.execute_async(
query,
parameters,
**execute_kwargs,
)
future.add_callbacks(
self._handle_result,
self._handle_error,
Expand Down
3 changes: 3 additions & 0 deletions libs/knowledge-store/ragstack_knowledge_store/graph_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ def __init__(
keyspace: str | None = None,
setup_mode: SetupMode = SetupMode.SYNC,
metadata_indexing: MetadataIndexingType = "all",
insert_timeout: float = 30.0,
):
self._insert_timeout = insert_timeout
if targets_table:
logger.warning(
"The 'targets_table' parameter is deprecated "
Expand Down Expand Up @@ -318,6 +320,7 @@ def add_nodes(
metadata_blob,
metadata_s,
),
timeout=self._insert_timeout,
)

return node_ids
Expand Down

0 comments on commit eb54a9f

Please sign in to comment.