Skip to content

Commit 680b9f8

Browse files
authored
Merge pull request #271 from technige/1.7-rollback-bug
[1.7.1] Fixes null connection bug
2 parents 9ede7eb + a6d65b2 commit 680b9f8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

neo4j/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,14 @@ def rollback_transaction(self):
643643
self._assert_open()
644644
if not self._transaction:
645645
raise TransactionError("No transaction to rollback")
646-
metadata = {}
647-
try:
648-
self._connection.rollback(on_success=metadata.update)
649-
finally:
650-
self._disconnect(sync=True)
651-
self._transaction = None
646+
cx = self._connection
647+
if cx:
648+
metadata = {}
649+
try:
650+
cx.rollback(on_success=metadata.update)
651+
finally:
652+
self._disconnect(sync=True)
653+
self._transaction = None
652654

653655
def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs):
654656
from neobolt.exceptions import ConnectionExpired, TransientError, ServiceUnavailable

0 commit comments

Comments
 (0)