eww.ioproxy¶
We replace sys.std[in, out, err] with instances of IOProxy. IOProxy provides a thread-local proxy to whatever we want to use for IO.
It is worth mentioning that this is not a perfect proxy. Specifically, it doesn’t proxy any magic methods. There are lots of ways to fix that, but so far it hasn’t been needed.
If you want to make modification to sys.std[in, out, err], any changes you make prior to calling embed will be respected and handled correctly. If you change the IO files after calling embed, everything will break. Ooof.
Fortunately, that’s a rare use case. In the event you want to though, you can use the register() and unregister() public APIs. Check out the Troubleshooting page for more information.
- class eww.ioproxy.IOProxy(original_file)[source]¶
Bases: object
IOProxy provides a proxy object meant to replace sys.std[in, out, err]. It does not proxy magic methods. It is used by calling the object’s register and unregister methods.
- __init__(original_file)[source]¶
Creates the thread local and registers the original file.
Parameters: original_file (file) – Since IOProxy is used to replace an existing file, original_file should be the file you’re replacing.
- __weakref__¶
list of weak references to the object (if defined)