summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-05-16 16:51:28 -0700
committerBob Halley <halley@dnspython.org>2020-05-16 16:52:13 -0700
commit6f3803a27dd74b0447795434682da8276a47ace0 (patch)
tree620ec71350cd646b90f364c8db559db77dd8571d /examples
parent02839ca4f1a4433d993efacb00fa34c7e80f2425 (diff)
downloaddnspython-6f3803a27dd74b0447795434682da8276a47ace0.tar.gz
Start trio async support.
Diffstat (limited to 'examples')
-rw-r--r--examples/trio.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/trio.py b/examples/trio.py
new file mode 100644
index 0000000..5bf889c
--- /dev/null
+++ b/examples/trio.py
@@ -0,0 +1,24 @@
+
+import sys
+import trio
+
+import dns.message
+import dns.trio.query
+
+async def main():
+ if len(sys.argv) > 1:
+ host = sys.argv[0]
+ else:
+ host = 'www.dnspython.org'
+ q = dns.message.make_query(host, 'A')
+ r = await dns.trio.query.udp(q, '8.8.8.8')
+ print(r)
+ q = dns.message.make_query(host, 'A')
+ r = await dns.trio.query.stream(q, '8.8.8.8')
+ print(r)
+ q = dns.message.make_query(host, 'A')
+ r = await dns.trio.query.stream(q, '8.8.8.8', tls=True)
+ print(r)
+
+if __name__ == '__main__':
+ trio.run(main)