summaryrefslogtreecommitdiff
path: root/pysnmp/carrier/twisted/dgram/unix.py
diff options
context:
space:
mode:
Diffstat (limited to 'pysnmp/carrier/twisted/dgram/unix.py')
-rw-r--r--pysnmp/carrier/twisted/dgram/unix.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/pysnmp/carrier/twisted/dgram/unix.py b/pysnmp/carrier/twisted/dgram/unix.py
index 5dc84bd3..61ccff93 100644
--- a/pysnmp/carrier/twisted/dgram/unix.py
+++ b/pysnmp/carrier/twisted/dgram/unix.py
@@ -17,6 +17,7 @@ class UnixTransportAddress(str, AbstractTransportAddress):
class UnixTwistedTransport(DgramTwistedTransport):
addressType = UnixTransportAddress
+ _lport = None
# AbstractTwistedTransport API
@@ -27,7 +28,7 @@ class UnixTwistedTransport(DgramTwistedTransport):
raise error.CarrierError(sys.exc_info()[1])
return self
- def openServerMode(self, iface=None):
+ def openServerMode(self, iface):
try:
self._lport = reactor.listenUNIXDatagram(iface, self)
except Exception:
@@ -36,8 +37,10 @@ class UnixTwistedTransport(DgramTwistedTransport):
return self
def closeTransport(self):
- d = self._lport.stopListening()
- d and d.addCallback(lambda x: None)
+ if self._lport is not None:
+ d = self._lport.stopListening()
+ if d:
+ d.addCallback(lambda x: None)
DgramTwistedTransport.closeTransport(self)
UnixTransport = UnixTwistedTransport