resolve_test_helper.py 476 B

1234567891011
  1. from __future__ import absolute_import, division, print_function
  2. from tornado.ioloop import IOLoop
  3. from tornado.netutil import ThreadedResolver
  4. # When this module is imported, it runs getaddrinfo on a thread. Since
  5. # the hostname is unicode, getaddrinfo attempts to import encodings.idna
  6. # but blocks on the import lock. Verify that ThreadedResolver avoids
  7. # this deadlock.
  8. resolver = ThreadedResolver()
  9. IOLoop.current().run_sync(lambda: resolver.resolve(u'localhost', 80))