I'm trying to update some properties in a Neo4j graph using Py2neo. I'd like to perform an atomic counter increment, then update some other properties only if the counter is a certain value. I also need to do this in a thread safe way so that other agents can't mess up the increment, or overwrite the property values before the entire set of values is committed. I believe it will look something like this:
tx = graph.cypher.begin()
try:
tx.acquireWriteLock(relationship) # from Java, not sure what this is in py2neo
count = relationship.getProperty("count", 1);
relationship.setProperty("count", count+1 );
if count == threshold:
relationship.setProperty("another_property", some_value );
tx.success();
finally:
tx.finish();
Some of the code above is guessed or taken from Java examples, If anyone could help with the python equivilant or point me in the direction of some example code that does the same I'd really appreciate it.