asynchat ready() method patch.

Donovan Baarda abo@m...
Sun, 28 Jan 2001 13:51:53 +1100


On Sat, Jan 27, 2001 at 05:42:37PM -0200, Julio Maia wrote:
> Hi,
> 
> I've modified that test script I've sent to you in order to try your new
> ready() patch. Now it seems to be calling ready() and more() properly,
> however it takes a long time between calls of ready() (about 30 seconds).
> Also, it seems the returned data from more() is not being processed
> correctly in the handler because of ready().

I never recieved your test scripts... I think the attachment went missing.
I'd be interested to see them though, so send me them again.

The 30 second delays are caused by the way asyncore.py works. The ready()
methods are called each iteration of the select() loop. The select loop
completes an iteration everytime an async event happens, or the select()
call times out. The default timeout in asyncore.py is 30 seconds... hence
the 30 second delay. One way to prove this is to establish another
connection to the medusa server before the 30 sec's expires, and this should
kick the select loop to re-calculate the ready() methods. A server that is
being hammered will not notice this problem because all the async events
will be kicking the event loop all the time. However, to get snapier
responces from an under-loaded server using ready(), set the timeout in
loop() to something lower, like 1 sec.

I dunno about the data not being processed correctly though... I'd have to
look at your code to figure it out. I suspect that your ready() methods are
not quite correct... ready() should return true and more() should return ''
when the producer is finished. If ready() does not return true when the the
producer is finished, asynchat will think that it is unfinished and blocked
forever, so asynchat will never complete.

> My script runs a http server on port 8000 by default. Any hits on it will
> (or should) return a pair of timestamps. Try to rename ready() to see how it
> should work.

I thought of renaming ready() to something else when I found the vestigial
ready() methods in filesys.py and status_handler.py. However, the code was
pretty complete by the time I found them, and the reality is there will
always be a potential problem with name clashes no-matter what name I choose.

-- 
----------------------------------------------------------------------
ABO: finger abo@m... for more info, including pgp key
----------------------------------------------------------------------