4 ms·
I have wanted something similar for Python: where the execution of a function will be interrupted (i.e. via a dedicated exception) and then I can rerun it to th
by blumomo 3y ago
I have wanted something similar for Python: where the execution of a function will be interrupted (i.e. via a dedicated exception) and then I can rerun it to the very same point it previously halted while none of prior side effects occur and the previous state within that function gets restored.
While I have an idea how to implement it, now after having read the article and comments here, how is this concept called? Does an implementation for Python exist already?
- bitdivision 3y agoIt's probably overkill depending on your use-case, but temporal has a python client: https://github.com/temporalio/sdk-python https://github.com/temporalio/sdk-python
- blumomo 3y agoThanks, that would solve it! Their „workflows“ provide a nice abstraction. Though I’d rather like to not include an external service. Imagine a simpler implementation for me where any earlier called subfunction would simply return the previous result, up to the point where the function was previously interrupted. Therefore these previous return values need to be stored (in what temporal calls a workflow), i.e. in a database. Sounds simple enough and decorators would probably help designing a good abstraction and keeping everything self-documenting and simple enough to understand.
- kodablah 3y agohttps://temporal.io/blog/durable-distributed-asyncio-event-loop https://temporal.io/blog/durable-distributed-asyncio-event-l... explains how it works
- amalcon 3y agoDepending on what you're trying to do, you likely want either continuations (which aren't supported in Python directly, but which you can emulate by writing your function in continuation-passing style) or a debugger with rewinding (which is fairly cutting edge, but might exist for Python? PyPy blogged about an early version a few years back). The main use cases for a specific point interrupt are covered by these techniques. That said, Temporal is very similar and supports multiple languages, including Python.
- Keyframe 3y agoDepending on what you need, but thinking for a bit in wider context then something like Prefect might be what you want.