'Python neo4j Result object hangs forever
I'm using the neo4j Python driver to run batched data loads on a local Neo4j database. I have the following packages:
neo4j==4.4.1
neo4j-driver==4.4.1
I am using the apoc.periodic.iterate method. The call returns a Result object which contains a small dictionary with some data about the load. It looks like this:
{'batches': 1,
'total': 9,
'timeTaken': 0,
'committedOperations': 9,
...}
When the load is very small, I can extract this object from Result and save it. When it is larger, however, I cannot work with the Result object. I am able to print the address of the object. But if I try to run any method on it, or extract data from it in anyway, or return it from the function, my code hangs forever. However, the return data should always be the same size, because it's just a bit of metadata about the load.
from neo4j import GraphDatabase
driver = GraphDatabase.driver(URI, auth=(user_name, password))
address = "test.csv"
cql = '''
CALL apoc.periodic.iterate(
"LOAD CSV WITH HEADERS FROM '%s' AS row
WITH
row.field1 AS field1,
toFloat(row.field2) AS field2
RETURN *",
"MERGE (tx: Object {field1: field1})
SET
tx.field1 = field1,
tx.field2 = field2;
",
{batchSize: 10000, parallel: true, retries: 3})
''' % address
with driver.session() as session:
result = session.run(cql)
print(result)
log_data = result.data()[0] # this line hangs forever with large loads
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
