forked from LBRYCommunity/lbry-sdk
cancel callLater on error or timeout
This commit is contained in:
parent
df78f7ff9f
commit
b4bc5e2110
1 changed files with 9 additions and 1 deletions
|
@ -173,6 +173,13 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
# Transmit the data
|
# Transmit the data
|
||||||
self._send(encodedMsg, msg.id, (contact.address, contact.port))
|
self._send(encodedMsg, msg.id, (contact.address, contact.port))
|
||||||
self._sentMessages[msg.id] = (contact.id, df, timeoutCall, method, args)
|
self._sentMessages[msg.id] = (contact.id, df, timeoutCall, method, args)
|
||||||
|
|
||||||
|
def cancel(err):
|
||||||
|
if timeoutCall.cancelled or timeoutCall.called:
|
||||||
|
return err
|
||||||
|
timeoutCall.cancel()
|
||||||
|
|
||||||
|
df.addErrback(cancel)
|
||||||
return df
|
return df
|
||||||
|
|
||||||
def startProtocol(self):
|
def startProtocol(self):
|
||||||
|
@ -336,6 +343,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
self._call_later_list[key] = delayed_call
|
self._call_later_list[key] = delayed_call
|
||||||
|
|
||||||
def _write_and_remove(self, key, txData, address):
|
def _write_and_remove(self, key, txData, address):
|
||||||
|
if key in self._call_later_list:
|
||||||
del self._call_later_list[key]
|
del self._call_later_list[key]
|
||||||
if self.transport:
|
if self.transport:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue