Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: ValueError: filedescriptor out of range in select()

Reply
Thread Tools

Re: ValueError: filedescriptor out of range in select()

 
 
Laszlo Nagy
Guest
Posts: n/a
 
      03-17-2009

> For whatever reason, you're ending up with a lot of open files and/or
> sockets
> (and/or any other resource based on file descriptors). That results
> in new
> file descriptors having large values (>=1024).
>
> You cannot use select() with such file descriptors. Try poll() instead,
> or Twisted.

Poll is not good, because it does not wait. I cannot call poll() in a
loop and have 100% CPU used for nothing. Well of course I could call
time.sleep() if there is nothing to receive/send. But then it would
increase response times dramatically. The only thing I can use is
select.select(). Or do you have another idea?

You are talking about twisted - can someone tell me how twisted does this?

>
> However, the use of select() you demonstrated is an unusual one, and not
> very good. It looks like the only purpose is to work around a bug in
> CPython on Windows where a process in a blocking read cannot be
> interrupted
> by C-c in the console?

Not just Ctrl+C. All of my threads are monitoring this event, and will
terminate within some seconds, if stop_requested.isSet(). This is a
multi-threaded program, and stop_requested.set() can be called from
several places:

- when a thread catches an exception that indicates an internal error in
the service
- when the program is killed, a TERM signal handler sets this event
- when Ctrl+C is pressed, in the main thread of the program
- when the program is requested to stop itself, over the network
- etc.

So for example, when I kill my program using the 'kill' command, it
cleans up everything before exiting.

I would really like to know what other options I have to implement this
efficiently. Is my approach bad?

Or am I using the wrong language? I started to use threads heavily in
the past months. Haskell might be a better choice for me, except that
Python is much more elegant.

Thanks,

Laszlo

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select() call and filedescriptor out of range in select error k3xji Python 5 09-16-2010 07:14 AM
ValueError: filedescriptor out of range in select() Laszlo Nagy Python 0 03-17-2009 02:04 PM
FILEDESCRIPTOR Structure question sarada7@gmail.com C++ 1 09-16-2006 03:13 AM
Re: filedescriptor out of range in select() Andrew Bennetts Python 5 06-30-2003 12:11 PM
filedescriptor out of range in select() Paolo Invernizzi Python 0 06-26-2003 07:45 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57