diff --git a/pysnmp/hlapi/asyncio/cmdgen.py b/pysnmp/hlapi/asyncio/cmdgen.py index 6d93d8f85..b7cca28ce 100644 --- a/pysnmp/hlapi/asyncio/cmdgen.py +++ b/pysnmp/hlapi/asyncio/cmdgen.py @@ -112,14 +112,13 @@ async def getCmd(snmpEngine, authData, transportTarget, contextData, >>> from pysnmp.hlapi.asyncio import * >>> >>> async def run(): - ... result_get = await getCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await getCmd( ... SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.pysnmp.com', 161)), ... ContextData(), ... ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)) ... ) - ... errorIndication, errorStatus, errorIndex, varBinds = await result_get ... print(errorIndication, errorStatus, errorIndex, varBinds) >>> >>> asyncio.run(run()) @@ -156,7 +155,7 @@ def __cbFun(snmpEngine, sendRequestHandle, vbProcessor.makeVarBinds(snmpEngine, varBinds), __cbFun, (options.get('lookupMib', True), future) ) - return future + return await future async def setCmd(snmpEngine, authData, transportTarget, contextData, @@ -218,14 +217,13 @@ async def setCmd(snmpEngine, authData, transportTarget, contextData, >>> from pysnmp.hlapi.asyncio import * >>> >>> async def run(): - ... set_result = await setCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await setCmd( ... SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.pysnmp.com', 161)), ... ContextData(), ... ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0), 'Linux i386') ... ) - ... errorIndication, errorStatus, errorIndex, varBinds = await set_result ... print(errorIndication, errorStatus, errorIndex, varBinds) >>> >>> asyncio.run(run()) @@ -262,7 +260,7 @@ def __cbFun(snmpEngine, sendRequestHandle, vbProcessor.makeVarBinds(snmpEngine, varBinds), __cbFun, (options.get('lookupMib', True), future) ) - return future + return await future async def nextCmd(snmpEngine, authData, transportTarget, contextData, @@ -328,14 +326,13 @@ async def nextCmd(snmpEngine, authData, transportTarget, contextData, >>> from pysnmp.hlapi.asyncio import * >>> >>> async def run(): - ... next_result = await nextCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await nextCmd( ... SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.pysnmp.com', 161)), ... ContextData(), ... ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')) ... ) - ... errorIndication, errorStatus, errorIndex, varBinds = await next_result ... print(errorIndication, errorStatus, errorIndex, varBinds) >>> >>> asyncio.run(run()) @@ -374,7 +371,7 @@ def __cbFun(snmpEngine, sendRequestHandle, vbProcessor.makeVarBinds(snmpEngine, varBinds), __cbFun, (options.get('lookupMib', True), future) ) - return future + return await future async def bulkCmd(snmpEngine, authData, transportTarget, contextData, @@ -468,7 +465,7 @@ async def bulkCmd(snmpEngine, authData, transportTarget, contextData, >>> from pysnmp.hlapi.asyncio import * >>> >>> async def run(): - ... result_bulk = await bulkCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await bulkCmd( ... SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.pysnmp.com', 161)), @@ -476,7 +473,6 @@ async def bulkCmd(snmpEngine, authData, transportTarget, contextData, ... 0, 2, ... ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')) ... ) - ... errorIndication, errorStatus, errorIndex, varBinds = await result_bulk ... print(errorIndication, errorStatus, errorIndex, varBinds) >>> >>> asyncio.run(run()) @@ -515,4 +511,4 @@ def __cbFun(snmpEngine, sendRequestHandle, vbProcessor.makeVarBinds(snmpEngine, varBinds), __cbFun, (options.get('lookupMib', True), future) ) - return future + return await future diff --git a/pysnmp/hlapi/asyncio/ntforg.py b/pysnmp/hlapi/asyncio/ntforg.py index 5b5915aac..e52687b82 100644 --- a/pysnmp/hlapi/asyncio/ntforg.py +++ b/pysnmp/hlapi/asyncio/ntforg.py @@ -101,14 +101,13 @@ async def sendNotification(snmpEngine, authData, transportTarget, contextData, >>> from pysnmp.hlapi.asyncio import * >>> >>> async def run(): - ... send_result = await sendNotification( + ... errorIndication, errorStatus, errorIndex, varBinds = await sendNotification( ... SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.pysnmp.com', 162)), ... ContextData(), ... 'trap', ... NotificationType(ObjectIdentity('IF-MIB', 'linkDown'))) - ... errorIndication, errorStatus, errorIndex, varBinds = await send_result ... print(errorIndication, errorStatus, errorIndex, varBinds) ... >>> asyncio.run(run()) @@ -159,4 +158,4 @@ def __trapFun(future): loop = asyncio.get_event_loop() loop.call_soon(__trapFun, future) - return future + return await future