select() on WinXP

G

grebekel

I'm running Python 2.5 on Windows XP. When I try to do this:

Code:
import select
select.select([], [], [])

I get this:

[output]
Traceback (most recent call last):
File "C:/Documents and Settings/Grebekel/Desktop/s.py", line 2, in
<module>
select.select([],[],[])
error: (10022, 'An invalid argument was supplied')
[/output]

Is there anything I should be aware of to get select() working under
Windows?
 
F

Fredrik Lundh

I'm running Python 2.5 on Windows XP. When I try to do this:

Code:
import select
select.select([], [], [])

I get this:

[output]
Traceback (most recent call last):
File "C:/Documents and Settings/Grebekel/Desktop/s.py", line 2, in
<module>
select.select([],[],[])
error: (10022, 'An invalid argument was supplied')
[/output]

Is there anything I should be aware of to get select() working under
Windows?

like, say, only calling select if you actually have something you want to select on?

(if you want to sleep, use time.sleep())

</F>
 
G

grebekel

I'm using it for sockets, it works on linux but not on Windows. The
actual code is something like (server side):

r, w, e = select.select(self.clients, [], self.clients, 5)

where self.clients is a list of accepted sockets.
 
T

Thomas Heller

I'm using it for sockets, it works on linux but not on Windows. The
actual code is something like (server side):

r, w, e = select.select(self.clients, [], self.clients, 5)

where self.clients is a list of accepted sockets.
The docs for select.select say:

Empty sequences are allowed, but acceptance of three empty sequences is platform-dependent.
(It is known to work on Unix but not on Windows.)

Thomas
 
G

grebekel

I patched the code to:

if self.clients:
r, w, e = select.select(self.clients, [], self.clients, 5)

It works now, thank you Thomas :)
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top