In some instances, it is necessary to promptly drop resources: for example, to grab a second request for Fastly's session-reuse feature. Currently, we use an ugly hack:
# Here we abuse an arbitrary request-consuming function to trigger
# the drop. Glue code interposed by wasmtime's linker ensures that
# drop happens, but send() otherwise fails before doing anything.
send(request, body, "no such backend")
Without this, a trap occurs at await_request(), IIRC. (If I don't recall correctly, it's at next_request().)
I see 2 ways out of this:
- Convince the Python runtime to drop things that Python itself GCs (either because refcount drops to 0 or because the cyclic GC ditches them). This would enable us to implement explicit drops in our SDK by simply saying
del some_resource behind nice abstractions. Customers could also call del if they wanted to program at a lower level. Most of the time, I imagine we could do nothing and let scope exits take care of dropping things.
- If that proves difficult for some reason, we could generate a
drop_foo() (likely in componentize-py) for each resource type foo and call those instead of del.
Open question:
- How are drops currently effected? Are they at all?
In some instances, it is necessary to promptly drop resources: for example, to grab a second request for Fastly's session-reuse feature. Currently, we use an ugly hack:
Without this, a trap occurs at
await_request(), IIRC. (If I don't recall correctly, it's atnext_request().)I see 2 ways out of this:
del some_resourcebehind nice abstractions. Customers could also calldelif they wanted to program at a lower level. Most of the time, I imagine we could do nothing and let scope exits take care of dropping things.drop_foo()(likely in componentize-py) for each resource typefooand call those instead ofdel.Open question: