wasmtime-py icon indicating copy to clipboard operation
wasmtime-py copied to clipboard

Using file objects (or equivalent) for stdio streams

Open whitequark opened this issue 5 years ago • 4 comments

Now that https://github.com/bytecodealliance/wasmtime-py/pull/33 is here, I understand that it's only possible to open a file on the host filesystem as an stdio stream. But that's (IMO) rarely useful: most WASI programs probably can accept data via files on the command line just as well as via stdio.

What I'd like to do is to capture stdout/stderr of a WASI application. Sure, I can do this by running a new host subprocess (with some caveats) but it would be a lot nicer if wasmtime-py provided this capability directly.

whitequark avatar Jun 23 '20 15:06 whitequark

This'll likely require significant implementation work on the C API side of things, but definitely possible to do. I think the underlying support was refactored to support arbitrary "handles" which we could bind as calling back to Python.

alexcrichton avatar Jun 23 '20 15:06 alexcrichton

Sounds good!

whitequark avatar Jun 23 '20 15:06 whitequark

This would be helpful in Perl as well. Is there a related issue for the C api in wasmtime?

plicease avatar Jun 23 '20 21:06 plicease

I don't believe so, but one would be most welcome!

alexcrichton avatar Jun 23 '20 21:06 alexcrichton