I have removed pysnmp and installed pysnmp-lextudio in an attempt to bring my codebase up to python 3.12.2
Code that ran with previous pysnmp versions now returns the error: 'tuple' object is not an iterator
Offending code is next() of last line:
from pysnmp.hlapi import *
g = getCmd(SnmpEngine(),
CommunityData('community', mpModel=1),
UdpTransportTarget((ipAddress, port)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)))
errorIndication, errorStatus, errorIndex, varBinds = next(g)
Any insight is welcome, device behaving via snmp walk.
Because whereas the library
pynsmpseems to return a generator from thegetCmdfunction (see documentation, thepysnmp-lexstudioalready performs the query.The example from
pynsmp-lextudiosite:And from the
pysnmpdocumentation:Why this has changed, I don't know, but notice the missing
next()on the first example.In fact, if you do just this:
You notice that the command is immediately called without
next.So tl;dr: in your old version,
gis a generator, in the new one it's a response.