def test_collision():
import resource
resource.setrlimit(resource.RLIMIT_NOFILE, (102400, 102400))
dd = {}
ls = []
for i in range(1 << 15):
key = str(hashlib.sha1(str(i)).hexdigest())
lck = key
print 'lock is', i, lck
l = Portlock(lck, timeout=8)
r = l.try_lock()
if not r:
print 'collide', i, l.addr
print l.socks
dd[l.addr] = i
ls.append(l)
评论列表
文章目录