using neo4j async

This commit is contained in:
Ken Wiltshire
2024-11-02 18:35:07 -04:00
parent 40e80ebc9d
commit f19af82db1
5 changed files with 141 additions and 179 deletions

View File

@@ -26,7 +26,7 @@ from .storage import (
)
from .kg.neo4j_impl import (
GraphStorage as Neo4JStorage
Neo4JStorage
)
#future KG integrations
@@ -57,9 +57,10 @@ def always_get_an_event_loop() -> asyncio.AbstractEventLoop:
try:
loop = asyncio.get_running_loop()
except RuntimeError:
logger.info("Creating a new event loop in a sub-thread.")
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
logger.info("Creating a new event loop in main thread.")
# loop = asyncio.new_event_loop()
# asyncio.set_event_loop(loop)
loop = asyncio.get_event_loop()
return loop
@@ -329,4 +330,4 @@ class LightRAG:
if storage_inst is None:
continue
tasks.append(cast(StorageNameSpace, storage_inst).index_done_callback())
await asyncio.gather(*tasks)
await asyncio.gather(*tasks)