summaryrefslogtreecommitdiff
path: root/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py')
-rw-r--r--examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py b/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py
index b45057e3..e5f493c0 100644
--- a/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py
+++ b/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py
@@ -22,11 +22,9 @@ from pysnmp.hlapi.asyncio import *
@asyncio.coroutine
-def run(varBinds):
- snmpEngine = SnmpEngine()
+def run(snmpEngine, varBinds):
while True:
- errorIndication, errorStatus, errorIndex, \
- varBindTable = yield from bulkCmd(
+ errorIndication, errorStatus, errorIndex, varBindTable = yield from bulkCmd(
snmpEngine,
UsmUserData('usr-none-none'),
UdpTransportTarget(('demo.snmplabs.com', 161)),
@@ -38,11 +36,8 @@ def run(varBinds):
print(errorIndication)
break
elif errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex) - 1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for varBindRow in varBindTable:
for varBind in varBindRow:
@@ -52,10 +47,11 @@ def run(varBinds):
if isEndOfMib(varBinds):
break
- snmpEngine.transportDispatcher.closeDispatcher()
+ yield from unconfigureCmdGen(snmpEngine)
+snmpEngine = SnmpEngine()
loop = asyncio.get_event_loop()
loop.run_until_complete(
- run([ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'))])
+ run(snmpEngine, [ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'))])
)