@@ -25,7 +25,6 @@ class which can be used to obtain `Driver` instances that are used for
2525managing sessions.
2626"""
2727
28-
2928from __future__ import division
3029
3130from collections import deque , namedtuple
@@ -34,10 +33,9 @@ class which can be used to obtain `Driver` instances that are used for
3433from .compat import integer , string , urlparse
3534from .connection import connect , Response , RUN , PULL_ALL
3635from .constants import ENCRYPTED_DEFAULT , TRUST_DEFAULT , TRUST_SIGNED_CERTIFICATES
37- from .exceptions import CypherError
36+ from .exceptions import CypherError , ProtocolError
3837from .types import hydrated
3938
40-
4139DEFAULT_MAX_POOL_SIZE = 50
4240
4341STATEMENT_TYPE_READ_ONLY = "r"
@@ -352,7 +350,6 @@ def contains_updates(self):
352350#: a list of sub-plans
353351Plan = namedtuple ("Plan" , ("operator_type" , "identifiers" , "arguments" , "children" ))
354352
355-
356353#: A profiled plan describes how the database executed your statement.
357354#:
358355#: db_hits:
@@ -440,6 +437,9 @@ def run(self, statement, parameters=None):
440437 :return: Cypher result
441438 :rtype: :class:`.StatementResult`
442439 """
440+ if self .transaction :
441+ raise ProtocolError ("Please close the currently open transaction object before running more "
442+ "statements/transactions in the current session." )
443443
444444 # Ensure the statement is a Unicode value
445445 if isinstance (statement , bytes ):
@@ -480,7 +480,9 @@ def begin_transaction(self):
480480
481481 :return: new :class:`.Transaction` instance.
482482 """
483- assert not self .transaction
483+ if self .transaction :
484+ raise ProtocolError ("Please close the currently open transaction object before running more "
485+ "statements/transactions in the current session." )
484486 self .transaction = Transaction (self )
485487 return self .transaction
486488
0 commit comments