question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

neomodel closes sessions only after object is deleted

See original GitHub issue

Using neomodel 3.2.5

I figured when using transaction with db.begin() and db.commit() it does not close the session immediately but when the object itself is being destroyed.

I used the following test to determine when the session is being close by using logging’s output to check when the object is being deleted (before the tearDown() or after) in test_session_closing_neomodel -> it closes session only after deleted in test_session_closing_neodriver -> it closes session when transaction is ended

import unittest
import logging
from neomodel import db
from neo4j.v1 import GraphDatabase
logging.basicConfig(level=logging.DEBUG)


class NeoTest(unittest.TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_session_closing_neomodel(self):
        db.set_connection("bolt://neo4j:neo4j@localhost:7687")
        db.begin()
        db.cypher_query("MATCH (n) RETURN n")
        db.commit()

    def test_session_closing_neodriver(self):
        driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "neo4j"))
        with driver.session() as session:
            with session.begin_transaction() as tx:
                tx.run("MATCH (n) RETURN n")
                tx.commit()

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
aanastasioucommented, Mar 8, 2019

@liranbg Right, sounds good, I have marked it as an enhancement and hope to see it taken care of relatively soon.

All the best

1reaction
robinedwardscommented, Jun 18, 2017

Thanks for raising this issue. Coupled to it is also the issue with the connection clean up causing some strange exceptions in neo4j_drivers destructor. Spent a while trying to figure it out to no avail but will let you know as soon as I find a solution

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modules documentation — neomodel 4.0.8 documentation
A singleton object via which all operations from neomodel to the Neo4j backend are ... specify True to get nodes with id only...
Read more >
neomodel doesn't save nodes in database - Stack Overflow
I found that when I create a User instance using cypher from neo4j console, User.nodes.all() returns such instance. So I guess the problem...
Read more >
Delete Endpoints and Resources - Amazon SageMaker
SageMaker frees up all of the resources that were deployed when the endpoint ... Deleting a SageMaker model only deletes the model entry...
Read more >
Object-Relational Mapping as a Persistence Mechanism for ...
The capacity to do so is called persistence. Without persistence, data exists only in memory and is lost when the computer shuts down....
Read more >
neomodel 1.0.1 - PyPI
An object mapper for the neo4j graph database. ... pip install neomodel==1.0.1 ... happens here jim.delete() jim.refresh() # reload properties from neo.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found