Commit 2436e476 authored by Martín Ferrari's avatar Martín Ferrari

some debugging msgs, and a small fix

parent 925ec4af
...@@ -23,6 +23,7 @@ class Node(object): ...@@ -23,6 +23,7 @@ class Node(object):
communication protocol are printed on stderr.""" communication protocol are printed on stderr."""
fd, pid = _start_child(debug, nonetns) fd, pid = _start_child(debug, nonetns)
self._pid = pid self._pid = pid
self._debug = debug
self._slave = netns.protocol.Client(fd, fd, debug) self._slave = netns.protocol.Client(fd, fd, debug)
self._processes = weakref.WeakValueDictionary() self._processes = weakref.WeakValueDictionary()
self._interfaces = weakref.WeakValueDictionary() self._interfaces = weakref.WeakValueDictionary()
...@@ -31,10 +32,12 @@ class Node(object): ...@@ -31,10 +32,12 @@ class Node(object):
Node._nextnode += 1 Node._nextnode += 1
def __del__(self): def __del__(self):
if self._debug: # pragma: no cover
sys.stderr.write("*** Node(%s) __del__\n" % self.pid)
self.destroy() self.destroy()
def destroy(self): def destroy(self):
if self.debug: # pragma: no cover if self._debug: # pragma: no cover
sys.stderr.write("*** Node(%s) destroy\n" % self.pid) sys.stderr.write("*** Node(%s) destroy\n" % self.pid)
for p in self._processes.values(): for p in self._processes.values():
p.destroy() p.destroy()
...@@ -94,9 +97,10 @@ class Node(object): ...@@ -94,9 +97,10 @@ class Node(object):
else: else:
ret.append(self._interfaces[i]) ret.append(self._interfaces[i])
# by the way, clean up _interfaces # by the way, clean up _interfaces
for i in self._interfaces: for i in list(self._interfaces): # copy before deleting!
if i not in ifaces: if i not in ifaces:
sys.stderr.write("WARNING: interface #%d went away." % i) if self._debug:
sys.stderr.write("WARNING: interface #%d went away." % i)
del self._interfaces[i] del self._interfaces[i]
return sorted(ret, key = lambda x: x.index) return sorted(ret, key = lambda x: x.index)
......
Markdown is supported
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