R
R
rodion-dev2015-03-13 23:15:04
Python
rodion-dev, 2015-03-13 23:15:04

Multithreaded python script, "filedescriptor out of range in select"?

there is a python script, many threads get an error,
and the more threads, the greater the number of messages about such errors.
for example, for 1000 threads there are almost none, and for 7000 threads it is full.
how to fix?
Traceback (most recent call last):
.....
File "parser.py", line 100, in getContent
r, w, e = select.select([s], [], [], 5)
ValueError: filedescriptor out of range in select()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
asd111, 2015-04-03
@asd111

use with or close files with close() after everything has been read
. either way

>>> with open('workfile.txt', 'r') as f:
...     read_data = f.read()
>>> f.closed
True

Either way
f = open('file.txt', 'r')

try:
    # do stuff with f
finally:
    f.close()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question