Skip to content

Retrievable transaction results #17545

Answered by cicdw
TheoMathurin asked this question in Ideas
Mar 20, 2025 · 2 comments · 8 replies
Discussion options

You must be logged in to vote

Ah good question - so you would need to explicitly write/stage something to the key set on the transaction using the stage method:

with transaction(key="my-key") as txn:
    if txn.is_committed():
        result = txn.read().result # will be "foobar" on a second run
    else:
        txn.stage(value="foobar") # will be persisted at transaction commit

Ultimately all of this transactions machinery is what backs Prefect's task result and cache storage mechanism, so it's possible you could get what you need using tasks directly.

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@cicdw
Comment options

Answer selected by TheoMathurin
@TheoMathurin
Comment options

@cicdw
Comment options

@TheoMathurin
Comment options

@TheoMathurin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants