import time
import dns.edns
+import dns.exception
import dns.message
import dns.name
import dns.query
# above the interval
time.sleep(6)
+ # named may be slow to enforce the send timeout under load; keep
+ # sending (without draining, to keep buffer pressure) until it closes.
+ deadline = time.time() + 30
with pytest.raises(EOFError):
try:
- dns.query.send_tcp(sock, msg, timeout())
- dns.query.receive_tcp(sock, timeout())
+ while time.time() < deadline:
+ try:
+ dns.query.send_tcp(sock, msg, timeout())
+ except dns.exception.Timeout:
+ # a blocked send is backpressure from named, not the
+ # close we are waiting for; keep probing
+ pass
+ # pace the probes; the pressure comes from the unread
+ # responses, not from the send rate
+ time.sleep(0.5)
except ConnectionError as e:
raise EOFError from e