[issue46116] _asyncio_backend.py datagram_received doesn't handle Future cancelled, throws Exception

2021-12-17 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

dns package is not a part of Python standard library.

Please file a bug in https://github.com/rthalley/dnspython/issues bugtracker.

P.S.
The fix is pretty straightforward:
if not fut.done():
fut.set_result(...)

--
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46116] _asyncio_backend.py datagram_received doesn't handle Future cancelled, throws Exception

2021-12-17 Thread James Lawrie


New submission from James Lawrie :

The datagram_received:

def datagram_received(self, data, addr):
if self.recvfrom:
self.recvfrom.set_result((data, addr))
self.recvfrom = None

Throws an exception if self.recvfrom is a Future Cancelled:

Exception in callback _SelectorDatagramTransport._read_ready()
handle: 
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 1021, in 
_read_ready
self._protocol.datagram_received(data, addr)
  File "/usr/local/lib/python3.8/dist-packages/dns/_asyncio_backend.py", line 
30, in datagram_received
self.recvfrom.set_result((data, addr))
asyncio.exceptions.InvalidStateError: invalid state

In my test code (attached), this wasn't caught in a try: catch:

--
components: asyncio
files: asynctest.py
messages: 408778
nosy: asvetlov, james2, yselivanov
priority: normal
severity: normal
status: open
title: _asyncio_backend.py datagram_received doesn't handle Future cancelled, 
throws Exception
versions: Python 3.8
Added file: https://bugs.python.org/file50500/asynctest.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com