]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
For async send_udp(), return a length and clarify the expiration
authorBob Halley <halley@dnspython.org>
Fri, 14 Oct 2022 01:10:34 +0000 (18:10 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 14 Oct 2022 01:10:34 +0000 (18:10 -0700)
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]

dns/_asyncio_backend.py
dns/asyncquery.py

index 736539bc9e5874d40560e3b0e5f97aa846d0d2a8..d8257658baded0842455057ae2bf37306e9e4531 100644 (file)
@@ -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
index 107f7667e00264eeda0f233da9bdd6ea66f3eb8a..bdf28eb994747249eb9c288fcff0cde7cf55266b 100644 (file)
@@ -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""