diff --git a/examples/python/graphiti_example.py b/examples/python/graphiti_example.py index 8a5c8e5f0..2a79110ea 100644 --- a/examples/python/graphiti_example.py +++ b/examples/python/graphiti_example.py @@ -69,4 +69,9 @@ async def main(): if __name__ == "__main__": setup_logging(logging.ERROR) - asyncio.run(main()) + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + loop.run_until_complete(main()) + finally: + loop.run_until_complete(loop.shutdown_asyncgens()) diff --git a/examples/python/multimedia_example.py b/examples/python/multimedia_example.py index 6c8bc5995..7355dd09f 100644 --- a/examples/python/multimedia_example.py +++ b/examples/python/multimedia_example.py @@ -1,9 +1,11 @@ import os import asyncio import pathlib +import logging import cognee from cognee.api.v1.search import SearchType +from cognee.shared.utils import setup_logging # Prerequisites: # 1. Copy `.env.template` and rename it to `.env`. @@ -45,4 +47,10 @@ async def main(): if __name__ == "__main__": - asyncio.run(main()) + setup_logging(logging.ERROR) + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + loop.run_until_complete(main) + finally: + loop.run_until_complete(loop.shutdown_asyncgens()) diff --git a/examples/python/simple_example.py b/examples/python/simple_example.py index bf3c95de1..27441bb45 100644 --- a/examples/python/simple_example.py +++ b/examples/python/simple_example.py @@ -1,6 +1,8 @@ import asyncio import cognee +import logging from cognee.api.v1.search import SearchType +from cognee.shared.utils import setup_logging # Prerequisites: # 1. Copy `.env.template` and rename it to `.env`. @@ -66,4 +68,10 @@ async def main(): if __name__ == "__main__": - asyncio.run(main()) + setup_logging(logging.ERROR) + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + loop.run_until_complete(main()) + finally: + loop.run_until_complete(loop.shutdown_asyncgens())