Verified Commit 90722fff authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Script: weak reference from SNMP

parent a34a242c
Pipeline #8127 passed with stages
in 5 minutes and 59 seconds
......@@ -858,8 +858,9 @@ class BaseScript(six.with_metaclass(BaseScriptMetaclass, object)):
def close_snmp(self):
if self.parent:
return
self.snmp.close()
self.snmp = None
if self.snmp:
self.snmp.close()
self.snmp = None
def mml(self, cmd, **kwargs):
"""
......
......@@ -2,10 +2,12 @@
# ----------------------------------------------------------------------
# SNMP methods implementation
# ----------------------------------------------------------------------
# Copyright (C) 2007-2015 The NOC Project
# Copyright (C) 2007-2018 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# Python modules
import weakref
# Third-party modules
import tornado.ioloop
import tornado.gen
......@@ -33,7 +35,7 @@ class SNMP(object):
SNMPError = SNMPError
def __init__(self, script):
self.script = script
self._script = weakref.ref(script)
self.ioloop = None
self.result = None
self.logger = PrefixLoggerAdapter(script.logger, self.name)
......@@ -41,6 +43,10 @@ class SNMP(object):
self.timeouts = 0
self.socket = None
@property
def script(self):
return self._script()
def set_timeout_limits(self, n):
"""
Set sequental timeouts l
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment