mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-04-27 22:25:37 +00:00
Handle potential race condition in request timeout
This commit is contained in:
parent
a420565ded
commit
a496e22ad1
1 changed files with 9 additions and 8 deletions
17
RNS/Link.py
17
RNS/Link.py
|
|
@ -1428,20 +1428,21 @@ class RequestReceipt():
|
|||
now = time.time()
|
||||
if now > self.__resource_response_timeout:
|
||||
self.request_timed_out(None)
|
||||
break
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
def request_timed_out(self, packet_receipt):
|
||||
self.status = RequestReceipt.FAILED
|
||||
self.concluded_at = time.time()
|
||||
self.link.pending_requests.remove(self)
|
||||
if self in self.link.pending_requests and self.status == RequestReceipt.DELIVERED:
|
||||
self.status = RequestReceipt.FAILED
|
||||
self.concluded_at = time.time()
|
||||
self.link.pending_requests.remove(self)
|
||||
|
||||
if self.callbacks.failed != None:
|
||||
try:
|
||||
self.callbacks.failed(self)
|
||||
except Exception as e:
|
||||
RNS.log("Error while executing request timed out callback from "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
if self.callbacks.failed != None:
|
||||
try: self.callbacks.failed(self)
|
||||
except Exception as e:
|
||||
RNS.log("Error while executing request timed out callback from "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
|
||||
def response_resource_progress(self, resource):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue