Closed solter closed 1 year ago
I'm pretty sure this is due to the following:
_close
variable to determine whether to emit the resource warning
_close
variable is only modified by setting it to true when close()
is called
Thus if resources are allocated (for example in the verify_connectivity
method) after the driver has been closed, the _closed
state is not reset.
Potential solutions:
_pool
object
_pool
since it is the only thing cleaned up by close()
_closed
flag is set_pool
is of type any_closed
flag so that it is reset to false any time a method is called that may allocate resources
_close
flagHello and thanks for reaching out :wave:
Well spotted. This is a weird quirk specific to the Python driver that we are already aware of. For Version 6.0 we planned to go with option 2 (choosing 6.0 as it's a breaking change). Why option 2? Because it's weird and surprising behavior that after closing a resource (here the driver) you can continue to use it. This might also result in us being limited on what we can and cannot do on driver closure if we don't want to break this. We consider using the driver after closure invalid usage of the driver. It's more an oversight than by design that it's currently working.
Bug Report
When the driver is used after it has been closed, it may open up new resources. But the
_closed
state is not reset, and so deleting a driver with open resources may leave abandoned, open resources.Example code
Here is an example of how this might occur:
My Environment
Python Version: 3.11 Driver Version: 5.10.0 Server Version and Edition: Neo4j Desktop, Neo4j DBMS 5.9.0 Operating System: Windows 10