Closed GoogleCodeExporter closed 9 years ago
Actually, the deadline given to @ndb.transactional() only applies to the
underlying begin_transaction() and commit() (or rollback()) operations. The
put() calls are unaffected.
You can probably implement this yourself easily, but you'll have to explicitly
compute and pass the deadline to each put() call:
@ndb.transactional()
def txn():
end_time = time.time() + 2
Model(b=1).put(deadline=end_time - time.time())
Model(b=2).put(deadline=end_time - time.time())
Original comment by guido@google.com
on 24 Oct 2012 at 2:13
I had mistakenly interpreted the following snippet in the docs as "calls
inherit **ctx_options from the decorator", rather than "decorator inherits
**ctx_options from Context".
"For some transaction-related functions, the following transaction options are
available (along with the inherited context options listed above)."
https://developers.google.com/appengine/docs/python/ndb/functions
I'll probably have to use a max(0,ms) though, because of this snippet I noticed
in the source. I assume this means -1 reverts to default timeout, and 0 raises
an exception immediately.
deadline: A double specifying the deadline for this call as the number of
seconds from the current time. Ignored if non-positive.
PS. Thanks!
Original comment by pdknsk
on 24 Oct 2012 at 1:05
I'd be suspicious of timeout 0. It may well mean "use default".
Original comment by guido@google.com
on 24 Oct 2012 at 1:58
When using retries, is the transaction cached somehow and just re-committed, or
basically re-run completely? In the former case this might have unexpected
results.
Original comment by pdknsk
on 24 Oct 2012 at 2:17
The function is re-run until it commits successfully or until you run out of
retries or until an unexpected exception happens.
Original comment by guido@google.com
on 24 Oct 2012 at 2:42
I have discarded the idea, because of the additional internal transaction
deadlines you mentioned (which I'm not familiar with). Essentially I could've
only made this work as transactional_deadline = deadline*2 +
deadline_in_function, which is fine more or less, but is too hackish for me.
Original comment by pdknsk
on 1 Nov 2012 at 5:39
Original issue reported on code.google.com by
pdknsk
on 21 Oct 2012 at 7:49