Possible Duplicate:
Can select() be used with files in Python under Windows?
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.
To more accurately describe what I am doing see https://github.com/eldarion/gondor-client/blob/ccbbf9d4b61ecbc2f66f510b993eb5fba0d81c09/gondor/run.py.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With