select() on WinXP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • grebekel@gmail.com

    select() on WinXP

    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?

  • Fredrik Lundh

    #2
    Re: select() on WinXP

    grebekel@gmail. com wrote:
    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>



    Comment

    • grebekel@gmail.com

      #3
      Re: select() on WinXP

      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(s elf.clients, [], self.clients, 5)

      where self.clients is a list of accepted sockets.

      Comment

      • Thomas Heller

        #4
        Re: select() on WinXP

        grebekel@gmail. com schrieb:
        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(s elf.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

        Comment

        • grebekel@gmail.com

          #5
          Re: select() on WinXP

          I patched the code to:

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

          It works now, thank you Thomas :)

          Comment

          Working...