Skip to content

Commit f8b6add

Browse files
Peter Wilhelmsson2hdddg
Peter Wilhelmsson
authored andcommitted
Reclassify exceptions as retryable
These errors from server should trigger a retry: Neo.ClientError.Cluster.NotALeader Neo.ClientError.General.ForbiddenOnReadOnlyDatabase
1 parent 19eb042 commit f8b6add

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

neo4j/exceptions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
+ ConstraintError
3232
+ AuthError
3333
+ Forbidden
34-
+ ForbiddenOnReadOnlyDatabase
35-
+ NotALeader
3634
+ DatabaseError
3735
+ TransientError
3836
+ DatabaseUnavailable
37+
+ NotALeader
38+
+ ForbiddenOnReadOnlyDatabase
3939
4040
+ DriverError
4141
+ TransactionError
@@ -174,7 +174,7 @@ class CypherTypeError(ClientError):
174174
"""
175175

176176

177-
class NotALeader(ClientError):
177+
class NotALeader(TransientError):
178178
"""
179179
"""
180180

@@ -184,7 +184,7 @@ class Forbidden(ClientError):
184184
"""
185185

186186

187-
class ForbiddenOnReadOnlyDatabase(Forbidden):
187+
class ForbiddenOnReadOnlyDatabase(TransientError):
188188
"""
189189
"""
190190

tests/stub/test_routingdriver.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def test_forgets_address_on_not_a_leader_error(driver_info, test_scripts, test_r
544544
with StubCluster(*test_scripts):
545545
with GraphDatabase.driver(driver_info["uri_neo4j"], auth=driver_info["auth_token"]) as driver:
546546
with driver.session(default_access_mode=WRITE_ACCESS, fetch_size=-1) as session:
547-
with pytest.raises(ClientError):
547+
with pytest.raises(TransientError):
548548
_ = session.run(*test_run_args)
549549

550550
pool = driver._pool
@@ -570,7 +570,7 @@ def test_forgets_address_on_forbidden_on_read_only_database_error(driver_info, t
570570
with StubCluster(*test_scripts):
571571
with GraphDatabase.driver(driver_info["uri_neo4j"], auth=driver_info["auth_token"]) as driver:
572572
with driver.session(default_access_mode=WRITE_ACCESS, fetch_size=-1) as session:
573-
with pytest.raises(ClientError):
573+
with pytest.raises(TransientError):
574574
_ = session.run(*test_run_args)
575575

576576
pool = driver._pool

0 commit comments

Comments
 (0)