Skip to content

Commit

Permalink
Cancel plumbing request task when request is canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
HRogge authored and chrysn committed Mar 24, 2020
1 parent 538afa8 commit 81a9e99
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion aiocoap/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,16 @@ def __init__(self, plumbing_request, loop, log):
else:
self.observation = None

loop.create_task(self._run())
self._runner = loop.create_task(self._run())

self.log = log

self.response.add_done_callback(self._response_cancellation_handler)

def _response_cancellation_handler(self, response):
if self.response.cancelled() and not self._runner.cancelled():
self._runner.cancel()

@staticmethod
def _add_response_properties(response, request):
response.request = request
Expand Down

0 comments on commit 81a9e99

Please sign in to comment.