reset _listeningPort and _listening Deferred on teardown

This commit is contained in:
Jack Robison 2018-05-23 20:41:41 -04:00
parent 3dfc6bd2cc
commit a952d2d2c8
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 3 additions and 0 deletions

View file

@ -159,6 +159,7 @@ class Node(MockKademliaHelper):
yield self.safe_stop_looping_call(self._change_token_lc)
if self._listeningPort is not None:
yield self._listeningPort.stopListening()
self._listeningPort = None
def start_listening(self):
if not self._listeningPort:

View file

@ -171,6 +171,8 @@ class KademliaProtocol(protocol.DatagramProtocol):
def startProtocol(self):
log.info("DHT listening on UDP %s:%i", self._node.externalIP, self._node.port)
if self._listening.called:
self._listening = defer.Deferred()
self._listening.callback(True)
return self._ping_queue.start()