From: Bob Halley Date: Fri, 14 Oct 2022 01:10:34 +0000 (-0700) Subject: For async send_udp(), return a length and clarify the expiration X-Git-Tag: v2.3.0rc1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db1f91ac57c54e909b24154944d2987123978e80;p=thirdparty%2Fdnspython.git For async send_udp(), return a length and clarify the expiration is meaningless. For async receive_udp(), document that the return type is always a 3-tuple, as opposed to being either a pair or a 3-tuple as in the sync version. (I chose to document rather than change the behavior as changing it broke dnspython tests and might possibly break other code.) [#848] --- diff --git a/dns/_asyncio_backend.py b/dns/_asyncio_backend.py index 736539bc..d8257658 100644 --- a/dns/_asyncio_backend.py +++ b/dns/_asyncio_backend.py @@ -63,6 +63,7 @@ class DatagramSocket(dns._asyncbackend.DatagramSocket): async def sendto(self, what, destination, timeout): # pragma: no cover # no timeout for asyncio sendto self.transport.sendto(what, destination) + return len(what) async def recvfrom(self, size, timeout): # ignore size as there's no way I know to tell protocol about it diff --git a/dns/asyncquery.py b/dns/asyncquery.py index 107f7667..bdf28eb9 100644 --- a/dns/asyncquery.py +++ b/dns/asyncquery.py @@ -96,7 +96,8 @@ async def send_udp( *expiration*, a ``float`` or ``None``, the absolute time at which a timeout exception should be raised. If ``None``, no timeout will - occur. + occur. The expiration value is meaningless for the asyncio backend, as + asyncio's transport sendto() never blocks. Returns an ``(int, float)`` tuple of bytes sent and the sent time. """ @@ -124,7 +125,10 @@ async def receive_udp( *sock*, a ``dns.asyncbackend.DatagramSocket``. See :py:func:`dns.query.receive_udp()` for the documentation of the other - parameters, exceptions, and return type of this method. + parameters, and exceptions. + + Returns a ``(dns.message.Message, float, tuple)`` tuple of the received message, the + received time, and the address where the message arrived from. """ wire = b""