Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit b6bdc54

Browse files
committed
add some basic error handling to the "done" methods
1 parent f6e6331 commit b6bdc54

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

neo4j_arrow/_client.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,16 @@ def write_nodes(self, nodes: Nodes,
268268

269269
def nodes_done(self) -> Dict[str, Any]:
270270
assert not self.debug or self.state == ClientState.FEEDING_NODES
271-
result = self._send_action("NODE_LOAD_DONE", { "name": self.graph })
272-
if result:
273-
self.state = ClientState.FEEDING_EDGES
274-
return result
271+
try:
272+
result = self._send_action("NODE_LOAD_DONE", { "name": self.graph })
273+
if result and result.get("name", None) == self.graph:
274+
self.state = ClientState.FEEDING_EDGES
275+
return result
276+
log.warn(f"invalid response for nodes_done: {result}")
277+
# TODO: what would cause this?
278+
return {}
279+
except Exception as e:
280+
raise error.interpret(e)
275281

276282
def write_edges(self, edges: Edges,
277283
model: Optional[Graph] = None,
@@ -302,14 +308,19 @@ def write_edges(self, edges: Edges,
302308
except Exception as e:
303309
raise e
304310

305-
306311
def edges_done(self) -> Dict[str, Any]:
307312
assert not self.debug or self.state == ClientState.FEEDING_EDGES
308-
result = self._send_action("RELATIONSHIP_LOAD_DONE",
309-
{ "name": self.graph })
310-
if result:
311-
self.state = ClientState.AWAITING_GRAPH
312-
return result
313+
try:
314+
result = self._send_action("RELATIONSHIP_LOAD_DONE",
315+
{ "name": self.graph })
316+
if result and result.get("name", None) == self.graph:
317+
self.state = ClientState.AWAITING_GRAPH
318+
return result
319+
log.warn(f"invalid response for edges_done: {result}")
320+
# TODO: what would cause this?
321+
return {}
322+
except Exception as e:
323+
raise error.interpret(e)
313324

314325
def read_edges(self, *, properties: Optional[List[str]] = None,
315326
relationship_types: List[str] = ["*"],

0 commit comments

Comments
 (0)