At Tuesday 5/12/2006 01:18, Linan wrote:

t=T('aVerySlowSite','/')
asyncore.loop()
for i in range(0,10):
        print '%d in main process' % i
                time.sleep(1)

Suppose it's asynchronous, couple of '%d in main process' lines should
be mixed in the output of T.handle_read(), right?

No. As you noticed, asyncore.loop (without arguments) won't return until all channels are closed.

But I found that
actually main process was blocked at asyncore.loop(), until the the
socket was closed.

Exactly.

My questions:
1, Did I do anything wrong?
2, Is it real asynchronous?
3, If not, where to get the real one(s)?

Perhaps you didn't understand the nature of asyncore processing. The idea is not to have many threads, each one blocking on its own (synchronous) socket processing. Instead, using a single thread which never blocks, and dispatches events to many instances, each one processing its own data. If you want to do other things mixed with network events, put those things inside the loop, that is, instead of asyncore.loop() do something like:

while asyncore.socket_map:
    asyncore.loop(1, count=1)
    // do other things


--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to