1. <small id='owxfC'></small><noframes id='owxfC'>

    <tfoot id='owxfC'></tfoot>
    <i id='owxfC'><tr id='owxfC'><dt id='owxfC'><q id='owxfC'><span id='owxfC'><b id='owxfC'><form id='owxfC'><ins id='owxfC'></ins><ul id='owxfC'></ul><sub id='owxfC'></sub></form><legend id='owxfC'></legend><bdo id='owxfC'><pre id='owxfC'><center id='owxfC'></center></pre></bdo></b><th id='owxfC'></th></span></q></dt></tr></i><div id='owxfC'><tfoot id='owxfC'></tfoot><dl id='owxfC'><fieldset id='owxfC'></fieldset></dl></div>
    1. <legend id='owxfC'><style id='owxfC'><dir id='owxfC'><q id='owxfC'></q></dir></style></legend>
        <bdo id='owxfC'></bdo><ul id='owxfC'></ul>
    2. 在 Windows 上的 select.select 中使用 sys.stdin

      时间:2023-09-02
      • <bdo id='0vS9W'></bdo><ul id='0vS9W'></ul>
          <tbody id='0vS9W'></tbody>

            <tfoot id='0vS9W'></tfoot>
            • <legend id='0vS9W'><style id='0vS9W'><dir id='0vS9W'><q id='0vS9W'></q></dir></style></legend>

              <small id='0vS9W'></small><noframes id='0vS9W'>

                <i id='0vS9W'><tr id='0vS9W'><dt id='0vS9W'><q id='0vS9W'><span id='0vS9W'><b id='0vS9W'><form id='0vS9W'><ins id='0vS9W'></ins><ul id='0vS9W'></ul><sub id='0vS9W'></sub></form><legend id='0vS9W'></legend><bdo id='0vS9W'><pre id='0vS9W'><center id='0vS9W'></center></pre></bdo></b><th id='0vS9W'></th></span></q></dt></tr></i><div id='0vS9W'><tfoot id='0vS9W'></tfoot><dl id='0vS9W'><fieldset id='0vS9W'></fieldset></dl></div>
                本文介绍了在 Windows 上的 select.select 中使用 sys.stdin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                可能重复:
                windows下python中的文件可以用select()吗?

                在 UNIX 上,我可以在 Python 中将 sys.stdin 传递给 select.select.我正在尝试在 Windows 上执行此操作,但 Windows 上 Python 中的 select.select 不允许这样做.

                On UNIX I am able to pass sys.stdin to select.select in Python. I am attempting to do this on Windows, but select.select in Python on Windows will not allow it.

                要更准确地描述我在做什么,请参阅 https://github.com/eldarion/gondor-client/blob/ccbbf9d4b61ecbc2f66f510b993eb5fba0d81c09/gondor/run.py.

                To more accurately describe what I am doing see https://github.com/eldarion/gondor-client/blob/ccbbf9d4b61ecbc2f66f510b993eb5fba0d81c09/gondor/run.py.

                unix_run_poll 函数是我试图在 Windows 上完成的.基本思想是,我有一个到服务器的套接字连接,该服务器已将流式标准输入、标准输出、标准错误连接到远程运行的进程,并且我从本地客户端与它进行交互,并使其看起来好像本地客户端正在运行过程.

                The unix_run_poll function is what I am trying to accomplish on Windows. The basic idea is that I have a socket connection to a server which has hooked up streaming stdin, stdout, stderr to a process running remotely and I am interacting with it from the local client and making it appear as if the local client is running the process.

                win32_run_poll 是我尝试将它移植到 Windows 的尝试,它确实可以工作.这有点不稳定,而且 IMO 的方法非常糟糕.

                The win32_run_poll is my attempt at porting it to Windows and it does work, sort of. It is a little wonky and the approach, IMO, is very bad.

                有人对如何改进有建议吗?对win32api的依赖不太理想,但我可以保留它.

                Does anyone have suggestions on how this can be improved? The dependency on win32api is less than ideal, but I am okay with keeping it.

                推荐答案

                Windows上select只针对socket定义,对任意文件句柄无效(windows没有文件描述符的概念).有关此问题的详细信息,请参阅 msdn 文档,在 python 文档中也提到了 select 模块.

                On Windows select is only defined for sockets, and will not work for arbitrary file handles (windows has no concept of file descriptors). For more information about this issue, see the msdn documentation, it is also mentioned in the python documentation for the select module.

                如果你想对任意文件使用轮询,你应该研究一些抽象轮询套接字和文件句柄的东西.这可能是您帖子的评论中提到的扭曲反应器,也可能是与 libuv 或其他一些绑定的 python 绑定您选择的事件库.

                If you want to use polling for arbitary files, you should look into something that abstracts polling sockets and file handles. This might be the twisted reactor referred to in a comment to your post, or it might be a python binding to libuv, or some other event library of your choice.

                这篇关于在 Windows 上的 select.select 中使用 sys.stdin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Python解释器阻止多线程DNS请求? 下一篇:多个写入作为单个处理

                相关文章

                <legend id='9rhRp'><style id='9rhRp'><dir id='9rhRp'><q id='9rhRp'></q></dir></style></legend>
                  • <bdo id='9rhRp'></bdo><ul id='9rhRp'></ul>
                  <i id='9rhRp'><tr id='9rhRp'><dt id='9rhRp'><q id='9rhRp'><span id='9rhRp'><b id='9rhRp'><form id='9rhRp'><ins id='9rhRp'></ins><ul id='9rhRp'></ul><sub id='9rhRp'></sub></form><legend id='9rhRp'></legend><bdo id='9rhRp'><pre id='9rhRp'><center id='9rhRp'></center></pre></bdo></b><th id='9rhRp'></th></span></q></dt></tr></i><div id='9rhRp'><tfoot id='9rhRp'></tfoot><dl id='9rhRp'><fieldset id='9rhRp'></fieldset></dl></div>

                  1. <small id='9rhRp'></small><noframes id='9rhRp'>

                    <tfoot id='9rhRp'></tfoot>