Using select([sys.stdin]) on windows xp

J

John Taylor

I am using some jabber code that uses this:
while(1):
inputs, outputs, errors = select.select([sys.stdin], [], [],1)

if sys.stdin in inputs:
doCmd(con,sys.stdin.readline())
else:
con.process(1)

However, I get this error:
select.error: (10038, 'An operation was attempted on something that is
not a socket')

According the the Python docs:
On Windows, the underlying select() function is provided by the
WinSock library, and does not handle file desciptors that don't
originate from WinSock.

So I was wondering how I can change the code above to run on windows
xp. Any help would greatly appreciated.

Thanks,
-John
 
J

Josiah Carlson

According the the Python docs:
On Windows, the underlying select() function is provided by the
WinSock library, and does not handle file desciptors that don't
originate from WinSock.

So I was wondering how I can change the code above to run on windows
xp. Any help would greatly appreciated.

Check out the windows ctypes or pywin32 libraries. You can get at
nearly all the underlying system calls with either of those two
libraries, though discovering which call you want may be a bit of a
chore.

- Josiah
 
D

Daniel Dittmar

John said:
According the the Python docs:
On Windows, the underlying select() function is provided by the
WinSock library, and does not handle file desciptors that don't
originate from WinSock.

The Win32 functions are
- WaitForSingleObject (to wait with a short timeout)
- GetStdHandle (to get at the Win32 handle for sys.stdin)

Try Mark Hammonds Win32 extension if these functions are exported to Python.

Another possibility would be to use threads.

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top