--- /dev/null
+#!/usr/bin/env python
+
+import fdb
+from fdb.tuple import pack, unpack
+import time
+
+fdb.api_version(710)
+
+db = fdb.open()
+
+@fdb.transactional
+def set_fdb_txn(tr, _key, value):
+ key = pack((_key, ))
+ _t = tr.get(key)
+ if _t is not None:
+ _v, = unpack(_t)
+ print(_v)
+
+ time.sleep(3)
+
+ tr.set(key, pack((value,)))
+ value = tr.get(key)
+
+ _v, = unpack(value)
+ print(_v)
+
+def set_manual_txn(db, _key, value):
+ key = pack((_key, ))
+
+ tr = db.create_transaction()
+
+ while True:
+ try:
+ # Read two values from the transaction snapshot
+ a = tr.get(key)
+ if a is not None:
+ _v, = unpack(a)
+ print(_v)
+
+ time.sleep(2)
+
+ # Write two key-value pairs to the transaction snapshot
+ tr.set(key, pack((time.monotonic_ns(), )))
+
+ # Try to commit the transaction, and wait for the result
+ tr.commit().wait()
+
+ # Success!
+ return
+ except fdb.FDBError as error:
+ # The transaction conflicted or there was a transient failure.
+ # Ask the FDB API whether and when to retry the error
+ # (Also resets the tr object to be ready to use again)
+ print(error)
+ retry = tr.on_error(error).wait()
+ print(retry)
+
+set_manual_txn(db, "key", time.monotonic_ns())