pysnmp增加内存

问题描述

我使用pysnmp创建了一个脚本来进行监视。 它可以工作,但是会增加内存使用率,直到Windows将其停止为止。 以下代码是从设备中获取价值的主要功能, 似乎我需要在每次函数调用后清理缓存。 谁能帮我

from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.smi.rfc1902 import ObjectIdentity

cmdGen = cmdgen.CommandGenerator()
temperatureMIB='1.3.6.1.4.1.5835.5.2.1000.1.33'
temperature1=''

def getdata_m1():
   
        errorIndication,errorStatus,errorIndex,varBinds = cmdGen.getCmd(
            cmdgen.CommunityData('public'),cmdgen.UdpTransportTarget(('10.128.113,149',161)),ObjectIdentity(temperatureMIB),)

        if errorIndication:
            print(errorIndication)
        elif errorStatus:
            print('%s at %s' % (errorStatus.prettyPrint(),errorIndex and varBinds[int(errorIndex) - 1] or '?'))
        else:
            for name,val in varBinds:
                list1.append(str(val))`enter code here`
        temperature1 = list1[0]
        print(temperature1)```

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)