Skip to content

Commit 7743473

Browse files
authored
Merge pull request #150 from technige/1.2-fix-broken-disconnect
Fixes #144
2 parents 1f2ab33 + d236f41 commit 7743473

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

neo4j/v1/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ def _disconnect(self, sync):
242242
if self._connection:
243243
if sync:
244244
self._connection.sync()
245-
self._connection.in_use = False
246-
self._connection = None
245+
if self._connection:
246+
self._connection.in_use = False
247+
self._connection = None
247248
self._connection_access_mode = None
248249

249250
def close(self):

test/integration/test_session.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@ def test_peek_at_different_stages(self):
551551
upcoming = result.peek()
552552
assert upcoming is None
553553

554+
def test_can_safely_exit_session_without_consuming_result(self):
555+
with self.driver.session() as session:
556+
session.run("RETURN 1")
557+
assert True
558+
554559

555560
class SessionCompletionTestCase(DirectIntegrationTestCase):
556561

0 commit comments

Comments
 (0)