Skip to content

Commit

Permalink
trying to fix async event loop issue
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDietzMorris committed Aug 1, 2024
1 parent a8d9004 commit 4a71c9f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion PLATER/services/util/graph_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import httpx
import time
import neo4j
import asyncio

from neo4j import unit_of_work
from opentelemetry import trace
Expand All @@ -28,7 +29,7 @@ def __init__(self,
database_name: str = 'neo4j'):
self.database_name = database_name
self.graph_db_uri = f'bolt://{host}:{port}'
self.neo4j_driver = neo4j.AsyncGraphDatabase.driver(self.graph_db_uri, auth=auth)
self.neo4j_driver = asyncio.run(self.get_async_driver(auth))
self.sync_neo4j_driver = neo4j.GraphDatabase.driver(self.graph_db_uri, auth=auth)
self._supports_apoc = None
logger.debug('PINGING NEO4J')
Expand All @@ -37,6 +38,9 @@ def __init__(self,
self.check_apoc_support()
logger.debug(f'SUPPORTS APOC : {self._supports_apoc}')

async def get_async_driver(self, auth):
return neo4j.AsyncGraphDatabase.driver(self.graph_db_uri, auth=auth)

@staticmethod
@unit_of_work(timeout=NEO4J_QUERY_TIMEOUT)
async def _async_cypher_tx_function(tx,
Expand Down

0 comments on commit 4a71c9f

Please sign in to comment.