Message10152
Logged In: YES
user_id=43919
Looking over the code a bit more, I see that my last message
wasn't entirely accurate. There does seem to be only one
lock for both gethostbyname and gethostbyaddr
(gethostbyname_lock is used for both).
This is a pretty simple test that illustrates the problem
I'm seeing. My previous work was on my OS X machine, but
this is Python 2.2 (#3, Mar 6 2002, 18:30:37) [C] on irix6.
#!/usr/bin/env python
#
# Copyright (c) 2002 Dustin Sallings <dustin@spy.net>
# $Id$
import threading
import socket
import time
class ResolveMe(threading.Thread):
hosts=['propaganda.spy.net', 'bleu.west.spy.net',
'mail.west.spy.net']
def __init__(self):
threading.Thread.__init__(self)
self.setDaemon(1)
def run(self):
# Run 100 times
for i in range(100):
for h in self.hosts:
nrv=socket.gethostbyname_ex(h)
arv=socket.gethostbyaddr(nrv[2][0])
try:
# Verify the hostname is correct
assert(h==nrv[0])
# Verify the two hostnames match
assert(nrv[0]==arv[0])
# Verify the two addresses match
assert(nrv[2]==arv[2])
except AssertionError:
print "Failed! Checking " + `h` + "
got, " \
+ `nrv` + " and " + `arv`
if __name__=='__main__':
for i in range(1,10):
print "Starting " + `i` + " threads."
threads=[]
for n in range(i):
rm=ResolveMe()
rm.start()
threads.append(rm)
for t in threads:
t.join()
print `i` + " threads complete."
time.sleep(60)
The output looks like this:
verde:/tmp 190> ./pytest.py
Starting 1 threads.
1 threads complete.
Starting 2 threads.
Failed! Checking 'propaganda.spy.net' got,
('mail.west.spy.net', [], ['66.149.231.226']) and
('mail.west.spy.net', [], ['66.149.231.226'])
Failed! Checking 'bleu.west.spy.net' got,
('mail.west.spy.net', [], ['66.149.231.226']) and
('mail.west.spy.net', [], ['66.149.231.226'])
[...] |
|
Date |
User |
Action |
Args |
2007-08-23 14:00:22 | admin | link | issue539175 messages |
2007-08-23 14:00:22 | admin | create | |
|