So Gremlin Python ( Tinkerpop 3 ) does not have transaction support. So only way to get transaction like behavior is to make sure you do everything in a single database traversal.
Because I am writing an ORM / OGM model as my base that means I needed to implement something that looks like optimistic locking all my own (only works on immutable write-only graphs). Its a huge pain in the ass.
Anyway after half a day I finally figured out this is the traversal I need to resolve my optimistic lock when creating a single new node in the DB:
session.g.E().has('dirty',1).aggregate('x').fold().V().has('dirty',1).aggregate('x').choose(_.V().hasLabel('account').has("fingerprint", "DEADF00D").hasNot('dirty').count().is(0), __.select('x').unfold().properties('dirty').drop()).iterate()
#programming #coding #Tinkerpop #tinkerpop3 #graphdb #graphtheory #python #gremlin