Skip to content

Commit ba414b7

Browse files
committed
fixed write conflicts and defaultdoc
1 parent 0bddcb0 commit ba414b7

5 files changed

Lines changed: 20 additions & 6 deletions

File tree

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.0.1
2+
=====
3+
4+
* Fixed max retries for write conflicts
5+
16
2.0
27
=====
38

pyArango/collection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def __init__(self, database, jsonData):
257257
"fulltext" : {},
258258
}
259259
self.indexes_by_name = {}
260-
self.defaultDocument = None #getDefaultDoc(self._fields, {})
260+
# self.defaultDocument = None #getDefaultDoc(self._fields, {})
261261
self._isBulkInProgress = False
262262
self._bulkSize = 0
263263
self._bulkCache = []
@@ -325,6 +325,7 @@ def createDocument(self, initDict = None):
325325
"""create and returns a completely empty document or one populated with initDict"""
326326
# res = dict(self.defaultDocument)
327327
res = self.getDefaultDocument()
328+
328329
if initDict is not None:
329330
res.update(initDict)
330331

pyArango/connection.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
from .ca_certificate import CA_Certificate
1616

17+
from json.decoder import JSONDecodeError
18+
1719
class JsonHook(object):
1820
"""This one replaces requests' original json() function. If a call to json() fails, it will print a message with the request content"""
1921
def __init__(self, ret):
@@ -50,11 +52,17 @@ def __call__(self, *args, **kwargs):
5052
kwargs["verify"] = self.verify
5153

5254
try:
53-
status_code = 1200
55+
do_retry = True
5456
retry = 0
55-
while status_code == 1200 and retry < self.max_conflict_retries :
57+
while do_retry and retry < self.max_conflict_retries :
5658
ret = self.fct(*args, **kwargs)
57-
status_code = ret.status_code
59+
do_retry = ret.status_code == 1200
60+
try :
61+
data = ret.json()
62+
do_retry = do_retry or ("errorNum" in data and data["errorNum"] == 1200)
63+
except JSONDecodeError:
64+
pass
65+
5866
retry += 1
5967
except:
6068
print ("===\nUnable to establish connection, perhaps arango is not running.\n===")

pyArango/document.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def reset(self, collection, jsonFieldInit = None, on_load_validation=False) :
227227

228228
def to_default(self):
229229
"""reset the document to the default values"""
230-
self.reset(self.collection, self.collection.defaultDocument)
230+
self.reset(self.collection, self.collection.getDefaultDocument())
231231

232232
def validate(self):
233233
"""validate the document"""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
setup(
1212
name='pyArango',
1313

14-
version='2.0',
14+
version='2.0.1',
1515

1616
description='An easy to use python driver for ArangoDB with built-in validation',
1717
long_description=long_description,

0 commit comments

Comments
 (0)