如果我使用一个CommandGenerator两次请求相同的ip,第一次超时为0,第二次超时为60,则所有结果均为“超时前未收到SNMP响应”,第二次的超时似乎不起作用。 每次创建CommandGenerator或请求不同的IP都会获得正确的结果。 我确定超时已传递给UdpTransportTarget,下面是我的零件代码:
_cmdgen = cmdgen.CommandGenerator()
import time
try:
#a = get_cmdgen()
start_time = time.time()
worker = SNMP(
"1.1.1.",
"public",
logger=logging,
port=161,
timeout=0,
retries=0,
device_info=device_info,
model_version=1
)
output = worker.bulk_get(_cmdgen,["1.3.6.1.2.1.1.1.0"])
print output
except Exception as e:
print str(e)
finally:
endtime = time.time()
print (endtime-start_time)
try:
#a = get_cmdgen()
start_time = time.time()
worker1 = SNMP(
"1.1.1.1",
"public",
logger=logging,
port=161,
timeout=60,
retries=0,
device_info=device_info,
model_version=1
)
output = worker1.bulk_get(_cmdgen,["1.3.6.1.2.1.1.1.0"])
print output
except Exception as e:
print str(e)
finally:
endtime1 = time.time()
print (endtime1-start_time)