select.select()

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Nov 23 03:29:12 CET 2013


On Fri, 22 Nov 2013 17:42:07 -0800, Bhanu Karthik wrote:

> please help me.. what does the following line do?
> 
> read_sockets,write_sockets,error_sockets =
> select.select(CONNECTION_LIST,[],[])

The select.select function takes three arguments (plus an optional 
fourth):

select.select(read_list, write_list, exception_list)

Each list should a list of the file descriptors you want to wait for. On 
Windows, only sockets are valid file descriptors. On Unix or Linux, you 
can use sockets, open file objects, or low-level file descriptors.

In this case, you only pass CONNECTION_LIST, the others are empty lists 
[]. CONNECTION_LIST is probably a list of sockets to be read. When they 
are ready for reading, select() will return three lists:

read_sockets  - a list of the sockets open for reading

write_sockets and error_sockets should both be empty lists, since you 
didn't request any of those to be opened.



-- 
Steven



More information about the Python-list mailing list