Commit b8826b7a authored by A. Jesse Jiryu Davis's avatar A. Jesse Jiryu Davis Committed by Denis Bilenko

Fix #349: threaded resolver hangs due to import lock

Patch by @ajdavis. https://github.com/gevent/gevent/issues/349#issuecomment-31665013

Close #350.
parent 6fe12a79
# Copyright (c) 2012 Denis Bilenko. See LICENSE for details.
import _socket
from gevent.hub import get_hub
from gevent.hub import get_hub, text_type
__all__ = ['Resolver']
# trigger import of encodings.idna to avoid https://github.com/gevent/gevent/issues/349
text_type('foo').encode('idna')
class Resolver(object):
expected_errors = Exception
......
import socket
import gevent.socket as gevent_socket
gevent_socket.getaddrinfo(u'gevent.org', None, socket.AF_INET)
# a deadlock is possible if we import a module that runs Gevent's getaddrinfo
# with a unicode hostname, which starts Python's getaddrinfo on a thread, which
# attempts to import encodings.idna but blocks on the import lock. verify
# that Gevent avoids this deadlock.
import getaddrinfo_module
del getaddrinfo_module # fix pyflakes
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment