00001 from __future__ import absolute_import, division, print_function, with_statement 00002 from tornado.ioloop import IOLoop 00003 from tornado.netutil import ThreadedResolver 00004 from tornado.util import u 00005 00006 # When this module is imported, it runs getaddrinfo on a thread. Since 00007 # the hostname is unicode, getaddrinfo attempts to import encodings.idna 00008 # but blocks on the import lock. Verify that ThreadedResolver avoids 00009 # this deadlock. 00010 00011 resolver = ThreadedResolver() 00012 IOLoop.current().run_sync(lambda: resolver.resolve(u('localhost'), 80))