nguyenngoc101
nguyenngoc101

Reputation: 1211

how many file descriptors can select() manage in python socket?

When my multi-threaded program run, an error is thrown. I guess select() manages file descriptors too much, but not sure. Can someone explain this for me?

readables,writeables,exceptional = select.select(inputs,outputs, [])
ValueError: filedescriptor out of range in select()

Upvotes: 2

Views: 2586

Answers (1)

Rostyslav Dzinko
Rostyslav Dzinko

Reputation: 40795

The problem is that select() usually has a built-in limit on filedescriptors it can manage (1024 on most systems). Try poll or epoll, that might help.

Also note that select() uses an inefficient algorithm to manage filedescriptors lookup. This algorithm has O(n) computational complexity, while epoll has O(1).

Upvotes: 3

Related Questions