Skip to content

Track scheduled driver index build tasks#1519

Open
RitwijParmar wants to merge 1 commit into
getzep:mainfrom
RitwijParmar:codex/driver-index-task-cleanup
Open

Track scheduled driver index build tasks#1519
RitwijParmar wants to merge 1 commit into
getzep:mainfrom
RitwijParmar:codex/driver-index-task-cleanup

Conversation

@RitwijParmar

Copy link
Copy Markdown

Summary

Fixes #1513 by keeping references to the constructor-scheduled index build tasks in the Neo4j and FalkorDB drivers, then cancelling/awaiting them during driver close before closing the underlying database client.

This prevents the fire-and-forget build_indices_and_constraints() task from being abandoned when a function-scoped event loop or short-lived application shuts down.

Changes

  • Store the scheduled index build task on Neo4jDriver and FalkorDriver
  • On close(), retrieve completed task exceptions or cancel and await pending tasks
  • Add regression coverage for pending index task cleanup in both drivers

Tests

  • /tmp/graphiti/.venv/bin/python -m ruff check graphiti_core/driver/neo4j_driver.py graphiti_core/driver/falkordb_driver.py tests/driver/test_neo4j_driver.py tests/driver/test_falkordb_driver.py
  • /tmp/graphiti/.venv/bin/python -m pytest tests/driver/test_neo4j_driver.py tests/driver/test_falkordb_driver.py

Result: 25 passed, 1 skipped.

I have read and agree to the Zep CLA.

@Naseem77

Copy link
Copy Markdown
Contributor

@RitwijParmar falkordb_driver.py changed on main so this no longer applies. Could you rebase? Also worth syncing with #1636 which touches the same lifecycle.

Signed-off-by: Ritwij Aryan Parmar <ritwij.aryan.parmar@gmail.com>
@RitwijParmar
RitwijParmar force-pushed the codex/driver-index-task-cleanup branch from a830335 to 5ec6d7f Compare July 23, 2026 01:11
@zep-cla-assistant

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. For privacy information, see our Privacy Notice. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: example@example.com

or

I have read the CLA Document and I hereby sign the CLA behalf of my company, e-mail: example@example.com

Signature is valid for 6 months.


This bot will be retriggered when the Contributor License Agreement comment has been provided. Posted by the CLA Assistant Lite bot.

@RitwijParmar

Copy link
Copy Markdown
Author

Rebased onto current main and pushed. The driver index task ownership and close-time cancellation are unchanged after the rebase.

I checked #1636 as well. It covers the same driver lifecycle area but a separate init-task issue, so this PR stays focused on retaining and cancelling the scheduled index-build task. Focused tests pass 27 with 1 skipped and Ruff is clean.

@RitwijParmar

Copy link
Copy Markdown
Author

I have read and agree to the Zep CLA on behalf of myself, e-mail: ritwij.aryan.parmar@gmail.com

@RitwijParmar

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: ritwij.aryan.parmar@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Neo4jDriver.__init__:57 schedules orphan create_task without cancel/await pair

2 participants