Python: non-blocking reading from a file / stream in Cygwin

If I were on a Unix system, I could do something like this in Python to open the file in non-blocking mode:

fd = os.open(filepath, os.O_NONBLOCK)

However, on Windows, os.O_NONBLOCK does not exist, and if we tried to use it, we would get a os 'module' object has no attribute O_NONBLOCK . We need to do something similar for non-blocking input: https://github.com/jonathanslenders/python-prompt-toolkit/blob/master/prompt_toolkit/terminal/win32_input.py#L99

How does non-blocking login work in Cygwin? Does Cygwin O_NONBLOCK something similar to the O_NONBLOCK parameter?

0
python terminal cygwin
source share
1 answer

O_NONBLOCK can be used in C programming. You can see the definitions in the header file / usr / include / sys / _default_fcntl.h

 #define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ #define O_NONBLOCK _FNONBLOCK 

You can try the magic number 0x4000 directly.

0
source share

All Articles