Mixing asyncore with threads

Thomas Jensen thomasNO at SPAM.obscure.dk
Mon Oct 22 19:45:56 EDT 2001


Lucio Torre <lucio at movilogic.com> wrote in
news:mailman.1003791264.11491.python-list at python.org: 

[snip (TJ) - CPU/IO bound server]
>>other trafic while calculating. The problem is, that select() will
>>block until it sees trafic on a readable or writeable port (AFAIK).
> 
> select does not necesarily blocks.
> the select bit goes like this: (from some of my code)
> 
>                      readable, writable, exceptional = 
> select.select([conn.fd], [], [], 0.2)
>                      if len(readable) > 0 :
>                          tmp = readable[0].recv(1024*8)
>                          # log byte count
>                          conn.read_b += len(tmp)
>                          conn.out_buff += tmp
>                          if tmp != "":
>                              conn.read_time = 
> time.clock()
> 
> 0.2 being the timeout for select. if you use 0, it will just never
> block. 

I see, somehow I had (wrongly) gotten the impression that 0 meant 
"block", when it's really None.
Problem is, a voice inside my head keeps whispering "busywait", but 
probably the overhead is neglectible :-)

[snip]

> cant help you with asyncore or threads, but i know you can use
> select for this. 

Thanks.

-- 
Best Regards
Thomas Jensen





More information about the Python-list mailing list