nac3core: support custom context managers #583
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#583
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "mwojcik/nac3:custom_context_managers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
closes #75
Untested yet on hardware (that's why WIP), but compiles the test/example, cargo fmt done
Also, should order of the exit calls be the same as enter (FIFO) or reversed (stack)?
Obviously it's a stack - read the Python docs, understand what context managers are supposed to do, and try it in the REPL.
0ffbbcef20
to77a6baa84c
77a6baa84c
to3a10aaed3e
@ -0,0 +79,4 @@
if __name__ == "__main__":
CtxMgr().run()
I think the RTIO stuff can be removed and then this can become a nac3standalone demo? Using RTIO here doesn't add anything.
Exceptions escaping the context manager are supposed to call
__exit__
I believe.It's just like:
So you copy/call the implementation of try/finally.
3a10aaed3e
tob083ec586c
moved the test back to nac3artiq as standalone does not support exceptions (more importantly
__nac3_resume
that's used is missing).followed
gen_try
and slimmed it down to behave asexcept
part didn't exist andfinally
was always there. Considered extracting the common code and introducing a new function to be used by bothgen_try
andgen_with
but that I didn't find any other places in this module doing that; a little bit of redundancy for clarity won't hurt I think.Also looked into rebuilding the body/handler/etc. and calling
gen_try
instead but trying to build all theLocated
Expr
s was a bit too much.3d87aea685
to9094c965f1
[WIP] nac3core: support custom context managersto nac3core: support custom context managers9094c965f1
to2c9222445a