Skip to content

Commit c17a574

Browse files
author
Zhen
committed
Merge branch '1.2' into 1.3
2 parents 0fb2782 + 3964711 commit c17a574

File tree

7 files changed

+16
-13
lines changed

7 files changed

+16
-13
lines changed

neo4j/v1/api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class Session(object):
209209

210210
def __init__(self, acquirer, max_retry_time=None, access_mode=None, bookmark=None):
211211
self._acquirer = acquirer
212-
self._max_retry_time = max_retry_time or DEFAULT_MAX_RETRY_TIME
212+
self._max_retry_time = DEFAULT_MAX_RETRY_TIME if max_retry_time is None else max_retry_time
213213
self._default_access_mode = access_mode or WRITE_ACCESS
214214
self._bookmark = bookmark
215215

@@ -422,8 +422,8 @@ def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs):
422422
RETRY_DELAY_MULTIPLIER,
423423
RETRY_DELAY_JITTER_FACTOR)
424424
last_error = None
425-
t0 = t1 = time()
426-
while t1 - t0 <= self._max_retry_time:
425+
t0 = time()
426+
while True:
427427
try:
428428
self._connect(access_mode)
429429
self._create_transaction()
@@ -437,8 +437,10 @@ def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs):
437437
last_error = error
438438
else:
439439
raise error
440-
sleep(next(retry_delay))
441440
t1 = time()
441+
if t1 - t0 > self._max_retry_time:
442+
break
443+
sleep(next(retry_delay))
442444
raise last_error
443445

444446
def read_transaction(self, unit_of_work, *args, **kwargs):

test/examples/base_application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020

2121
from neo4j.v1 import GraphDatabase
2222

23+
2324
class BaseApplication(object):
2425
def __init__(self, uri, user, password):
25-
self._driver = GraphDatabase.driver( uri, auth=( user, password ) )
26+
self._driver = GraphDatabase.driver(uri, auth=( user, password ), max_retry_time=0)
2627

2728
def close(self):
2829
self._driver.close()

test/examples/config_max_retry_time_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
from neo4j.v1 import GraphDatabase
2323
# end::config-max-retry-time-import[]
2424

25+
2526
class ConfigMaxRetryTimeExample:
2627
# tag::config-max-retry-time[]
2728
def __init__(self, uri, user, password):
28-
self._driver = GraphDatabase.driver(uri, auth=(user, password),
29-
Config.build().withMaxTransactionRetryTime( 15, SECONDS ).toConfig() )
29+
self._driver = GraphDatabase.driver(uri, auth=(user, password), max_retry_time=15)
3030
# end::config-max-retry-time[]
3131

3232
def close(self):

test/examples/config_trust_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
# limitations under the License.
2020

2121
# tag::config-trust-import[]
22-
from neo4j.v1 import GraphDatabase
22+
from neo4j.v1 import GraphDatabase, TRUST_ALL_CERTIFICATES
2323
# end::config-trust-import[]
2424

25+
2526
class ConfigTrustExample:
2627
# tag::config-trust[]
2728
def __init__(self, uri, user, password):
28-
self._driver = GraphDatabase.driver(uri, auth=(user, password),
29-
Config.build().withTrustStrategy( Config.TrustStrategy.trustSystemCertificates() ).toConfig() )
29+
self._driver = GraphDatabase.driver(uri, auth=(user, password), trust=TRUST_ALL_CERTIFICATES)
3030
# end::config-trust[]
3131

3232
def close(self):

test/examples/config_unencrypted_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
from neo4j.v1 import GraphDatabase
2323
# end::config-unencrypted-import[]
2424

25+
2526
class ConfigUnencryptedExample:
2627
# tag::config-unencrypted[]
2728
def __init__(self, uri, user, password):
2829
self._driver = GraphDatabase.driver(uri, auth=(user, password), encrypted=False)
2930
# end::config-unencrypted[]
3031

3132
def close(self):
32-
self._driver.close();
33+
self._driver.close()

test/examples/test_examples.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ def test_transaction_function_example(self):
156156

157157
self.assertEqual(self.person_count("Alice"), 1)
158158

159-
160159
def read(self, statement):
161160
from neo4j.v1 import GraphDatabase
162161
with GraphDatabase.driver(self.bolt_uri, auth=self.auth_token) as driver:

test/stub/test_directdriver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_direct_should_reject_routing_context(self):
5757
def test_direct_session_close_after_server_close(self):
5858
with StubCluster({9001: "disconnect_after_init.script"}):
5959
uri = "bolt://127.0.0.1:9001"
60-
with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False) as driver:
60+
with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False, max_retry_time=0) as driver:
6161
with driver.session() as session:
6262
with self.assertRaises(ServiceUnavailable):
6363
session.write_transaction(lambda tx: tx.run("CREATE (a:Item)"))

0 commit comments

Comments
 (0)