neo4j-contrib / neomodel

An Object Graph Mapper (OGM) for the Neo4j graph database.
https://neomodel.readthedocs.io
MIT License
939 stars 231 forks source link

Relying on Driver's destructor to close the session is deprecated. #736

Closed aymenalitaleb closed 1 year ago

aymenalitaleb commented 1 year ago

Expected Behavior (Mandatory)

I was expecting the driver to close automaticlly, since I upgraded neo4j to 5.11.0 I started having this problem. Note that I'm not using from neo4j import GraphDatabase.

Actual Behavior (Mandatory)

****\venv\lib\site-packages\neo4j\_sync\driver.py:485: ResourceWarning: Unclosed <neo4j._sync.driver.BoltDriver object at 0x000001A7D7B1F370>.
Enable tracemalloc to get the object allocation traceback.
****\venv\lib\site-packages\neo4j\_sync\driver.py:489: DeprecationWarning: Relying on Driver's destructor to close the session is deprecated. Please make sure to close the session. Use it as a context (`with` statement) or make sure to call `.close()` explicitly. Future versions of the driver will not close drivers automatically.

How to Reproduce the Problem

Anytime I try to interact with the database

Screenshots (where it's possibile)

Specifications (Mandatory)

Currently used versions 5.1.0

Versions

aanastasiou commented 1 year ago

Hello @aymenalitaleb , please see notes on this PR regarding managing the driver.