[Zope] Asynchronous DTML

Andrew Kenneth Milton akm@theinternet.com.au
Fri, 5 Oct 2001 12:52:55 +1000

+-------[ Chris McDonough ]----------------------
| It depends on the host system's gethostbyaddr, I suppose.  Is there a 
| reason you can't concurrently do more than one DNS lookup that you can 
| think of?

Well first you're in a system call, so your whole process will block while
it's inside kernel space, especially on those systems whose kernels don't
have threaded kernels. If it takes two minutes for your systemcall to
complete, then your process will block for two minutes. gethostbyname also 
uses static storage to return results. This is why Netscape, Squid, Mozilla 
et. al have DNS helper applications that do DNS lookups in a seperate forked 
process (not thread). They also have alarms around it to interrupt the
call after about 30 seconds, since it's probably not coming back if it
takes that long.

You have to explicitly use gethostbyname_r to get the MP-Safe resolver,
I don't know if Python does this (I'm not a python internals guru), that's
why I ask. Calling _r routines doesn't guarantee that you'll get concurrent
lookups either, it just means that multiple threads calling gethostbyname_r
won't trash each other.

Totally Holistic Enterprises Internet|                      | Andrew Milton
The Internet (Aust) Pty Ltd          |                      |
ACN: 082 081 472 ABN: 83 082 081 472 |  M:+61 416 022 411   | Carpe Daemon
PO Box 837 Indooroopilly QLD 4068    |akm@theinternet.com.au|