简体   繁体   English

异步传输/协议的文件描述符

[英]File Descriptors to asyncio transport/protocol

Ok, so, I have a Base Protocol and specializations for Streams and Subprocess.好的,所以,我有一个基本协议和流和子进程的专业化。 I am also trying to rig it up for inherited file descriptors (namely, stdio).我还试图为继承的文件描述符(即 stdio)装配它。 This is useful for proxying over ssh, systemd socket activation, etc.这对于通过 ssh 进行代理、systemd 套接字激活等很有用。

To be clear, I need to get asyncio to wire up a reader file descriptor and writer file descriptor to a Transport and construct a Protocol from it.明确地说,我需要让 asyncio 将读取器文件描述符和写入器文件描述符连接到传输并从中构造协议。

Unfortunately, there doesn't seem to be anything for that?不幸的是,似乎没有什么可以做的? I can ask it to watch descriptors or get stream objects for them, but I can't seem to wire them up to a transport/protocol pair.我可以要求它查看描述符或为它们获取流对象,但我似乎无法将它们连接到传输/协议对。

I ended up writing a proxy transport/protocol object: It can act as the protocol for the reader/writer transports, and act as a transport for the actual protocol, shuffling data between all three.我最终编写了一个代理传输/协议对象:它可以充当读取器/写入器传输的协议,并充当实际协议的传输,在所有三个之间混洗数据。

https://github.com/minecraft-podman/urp/blob/8ed78d12c8abfa7ef067892dda25149d023b03fc/urp/common.py#L286-L364 https://github.com/minecraft-podman/urp/blob/8ed78d12c8abfa7ef067892dda25149d023b03fc/urp/common.py#L286-L364

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM