如果我在Unix系统上,那么我可以用Python做这样的事情来打开非阻塞模式的文件:
fd = os.open(filepath, os.O_NONBLOCK)
但是,在Windows中,os.O_NONBLOCK
不存在,如果我们尝试使用它,则会遇到os
模块错误'module' object has no attribute O_NONBLOCK
。对于非阻塞输入,我们必须执行类似的操作:https://github.com/jonathanslenders/python-prompt-toolkit/blob/master/prompt_toolkit/terminal/win32_input.py#L99
虽然非阻塞输入如何在Cygwin中工作? Cygwin是否模仿类似O_NONBLOCK
选项的内容?
答案 0 :(得分:0)
O_NONBLOCK可用于C编程。您可以在头文件/usr/include/sys/_default_fcntl.h中看到定义
#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
#define O_NONBLOCK _FNONBLOCK
您可以直接尝试幻数0x4000。