Skip to content

Commit

Permalink
use clock time not trio time
Browse files Browse the repository at this point in the history
  • Loading branch information
rthalley committed May 21, 2020
1 parent a32bac9 commit 198cf1a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dns/trio/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import socket
import struct
import time
import trio
import trio.socket # type: ignore

Expand Down Expand Up @@ -38,7 +39,7 @@ async def send_udp(sock, what, destination):

if isinstance(what, dns.message.Message):
what = what.to_wire()
sent_time = trio.current_time()
sent_time = time.time()
n = await sock.sendto(what, destination)
return (n, sent_time)

Expand Down Expand Up @@ -84,7 +85,7 @@ async def receive_udp(sock, destination, ignore_unexpected=False,
raise UnexpectedSource('got a response from '
'%s instead of %s' % (from_address,
destination))
received_time = trio.current_time()
received_time = time.time()
r = dns.message.from_wire(wire, keyring=keyring, request_mac=request_mac,
one_rr_per_rrset=one_rr_per_rrset,
ignore_trailing=ignore_trailing)
Expand Down Expand Up @@ -159,7 +160,7 @@ async def send_stream(stream, what):
# avoid writev() or doing a short write that would get pushed
# onto the net
stream_message = struct.pack("!H", l) + what
sent_time = trio.current_time()
sent_time = time.time()
await stream.send_all(stream_message)
return (len(stream_message), sent_time)

Expand Down Expand Up @@ -201,7 +202,7 @@ async def receive_stream(stream, one_rr_per_rrset=False, keyring=None,
ldata = await _read_exactly(stream, 2)
(l,) = struct.unpack("!H", ldata)
wire = await _read_exactly(stream, l)
received_time = trio.current_time()
received_time = time.time()
r = dns.message.from_wire(wire, keyring=keyring, request_mac=request_mac,
one_rr_per_rrset=one_rr_per_rrset,
ignore_trailing=ignore_trailing)
Expand Down Expand Up @@ -260,7 +261,7 @@ async def stream(q, where, tls=False, port=None, source=None, source_port=0,
dns.query._destination_and_source(None, where, port, source,
source_port)
with socket_factory(af, socket.SOCK_STREAM, 0) as s:
begin_time = trio.current_time()
begin_time = time.time()
if source is not None:
await s.bind(source)
await s.connect(destination)
Expand Down

0 comments on commit 198cf1a

Please sign in to comment.