@@ -191,9 +191,8 @@ class DirectDriver(Driver):
191191
192192 def __new__ (cls , uri , ** config ):
193193 from neobolt .addressing import SocketAddress
194- from neobolt .compat .ssl import SSL_AVAILABLE
195194 from neobolt .direct import ConnectionPool , DEFAULT_PORT , connect
196- from neobolt .security import ENCRYPTION_OFF , ENCRYPTION_ON , SecurityPlan
195+ from neobolt .security import ENCRYPTION_OFF , ENCRYPTION_ON , SSL_AVAILABLE , SecurityPlan
197196 cls ._check_uri (uri )
198197 if SocketAddress .parse_routing_context (uri ):
199198 raise ValueError ("Parameters are not supported with scheme 'bolt'. Given URI: '%s'." % uri )
@@ -234,10 +233,9 @@ class RoutingDriver(Driver):
234233
235234 def __new__ (cls , uri , ** config ):
236235 from neobolt .addressing import SocketAddress
237- from neobolt .compat .ssl import SSL_AVAILABLE
238236 from neobolt .direct import DEFAULT_PORT , connect
239237 from neobolt .routing import RoutingConnectionPool
240- from neobolt .security import ENCRYPTION_OFF , ENCRYPTION_ON , SecurityPlan
238+ from neobolt .security import ENCRYPTION_OFF , ENCRYPTION_ON , SSL_AVAILABLE , SecurityPlan
241239 cls ._check_uri (uri )
242240 instance = object .__new__ (cls )
243241 instance .initial_address = initial_address = SocketAddress .from_uri (uri , DEFAULT_PORT )
@@ -441,6 +439,9 @@ def run(self, statement, parameters=None, **kwparameters):
441439 parameters = fix_parameters (dict (parameters or {}, ** kwparameters ), protocol_version ,
442440 supports_bytes = server .supports ("bytes" ))
443441
442+ def fail (_ ):
443+ self ._close_transaction ()
444+
444445 hydrant = PackStreamHydrator (protocol_version )
445446 metadata = {
446447 "statement" : statement ,
@@ -449,11 +450,12 @@ def run(self, statement, parameters=None, **kwparameters):
449450 "protocol_version" : protocol_version ,
450451 }
451452 self ._last_result = result = BoltStatementResult (self , hydrant , metadata )
452- cx .run (statement , parameters , on_success = metadata .update )
453+ cx .run (statement , parameters , on_success = metadata .update , on_failure = fail )
453454 cx .pull_all (
454- on_success = metadata .update ,
455455 on_records = lambda records : result ._records .extend (
456456 hydrant .hydrate_records (result .keys (), records )),
457+ on_success = metadata .update ,
458+ on_failure = fail ,
457459 on_summary = lambda : result .detach (sync = False ),
458460 )
459461
0 commit comments