8000 Wait for sync upon graph creation · arangodb/python-arango@e7bcd4d · GitHub
[go: up one dir, main page]

Skip to content

Commit e7bcd4d

Browse files
committed
Wait for sync upon graph creation
1 parent c6e923b commit e7bcd4d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

arango/database.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,7 @@ def create_graph(
16991699
replication_factor: Optional[int] = None,
17001700
write_concern: Optional[int] = None,
17011701
satellite_collections: Optional[Sequence[str]] = None,
1702+
sync: Optional[bool] = None,
17021703
) -> Result[Graph]:
17031704
"""Create a new graph.
17041705
@@ -1753,6 +1754,8 @@ def create_graph(
17531754
element must be a string and a valid collection name. The
17541755
collection type cannot be modified later.
17551756
:type satellite_collections: [str] | None
1757+
:param sync: Wait until everything is synced to disk.
1758+
:type sync: bool | None
17561759
:return: Graph API wrapper.
17571760
:rtype: arango.graph.Graph
17581761
:raise arango.exceptions.GraphCreateError: If create fails.
@@ -1796,7 +1799,16 @@ def create_graph(
17961799
if satellite_collections is not None: # pragma: no cover
17971800
data["options"]["satellites"] = satellite_collections
17981801

1799-
request = Request(method="post", endpoint="/_api/gharial", data=data)
1802+
params: Params = {}
1803+
if sync is not None:
1804+
params["waitForSync"] = sync
1805+
1806+
request = Request(
1807+
method="post",
1808+
endpoint="/_api/gharial",
1809+
data=data,
1810+
params=params,
1811+
)
18001812

18011813
def response_handler(resp: Response) -> Graph:
18021814
if resp.is_success:

tests/test_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_graph_properties(graph, bad_graph, db):
5151
bad_graph.properties()
5252

5353
new_graph_name = generate_graph_name()
54-
new_graph = db.create_graph(new_graph_name)
54+
new_graph = db.create_graph(new_graph_name, sync=True)
5555
properties = new_graph.properties()
5656
assert properties["id"] == f"_graphs/{new_graph_name}"
5757
assert properties["name"] == new_graph_name

0 commit comments

Comments
 (0)
0