asyncore and (missing) timeout

Pierre HANSER pierre.hanser at sxb.bsf.alcatel.fr
Mon Jun 23 10:32:17 EDT 2003


hello

I'm trying to use asyncore with some timeout in the poll loop
to not use all my cpu.

The problem I have is that operationnal sockets always return
immediatly to a select with write, as you CAN write immediatly on them.

I've tried a minor modification:

            try:
                r,wIgnore,e = select.select (r,[],e, timeout)
            except select.error, err:
                if err[0] != EINTR:
                    raise
                r = []; w = []; e = []
        try:
            rIgnore,w,eIgnore = select.select ([],w,[], timeout)
        except select.error, err:
            if err[0] != EINTR:
                raise
            r = []; w = []; e = []

which consist in doing first the select on readable objects, which
most of the times goes until timeout, and only afterwards do
the select on write objects, which will probably return immediately.

My question is: is there a better way to regain some CPU when using
asyncore?

The solution of returning a significant value in "writable" function
is a bit cumbersome as you have to manage there the fact you will
want to write something one day...
 
-- 
	Pierre Hanser





More information about the Python-list mailing list