Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import six.moves.http_client locks interpreter #261

Open
pelson opened this issue Oct 4, 2018 · 0 comments
Open

import six.moves.http_client locks interpreter #261

pelson opened this issue Oct 4, 2018 · 0 comments

Comments

@pelson
Copy link

pelson commented Oct 4, 2018

When importing six.moves.http_client within a script my interpreter freezes up. I don't get the same behaviour when importing in the REPL:

$ python       
Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51) 
[GCC 7.2.0] on linux
...
>>> import six.moves.http_client
>>> 
$ cat foo.py
import six
print('Six version: ', six.__version__)
import six.moves.http_client
print('six.moves.http_client')

$ python foo.py
Six version:  1.11.0
...
<wait a very long time and then KeyboardInterrupt to get some traceback>
...
^CTraceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 888, in _find_spec
AttributeError: '_SixMetaPathImporter' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "foo.sh", line 3, in <module>
    import six.moves.http_client
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 890, in _find_spec
  File "<frozen importlib._bootstrap>", line 867, in _find_spec_legacy
  File "<frozen importlib._bootstrap>", line 449, in spec_from_loader
  File "lib/python3.6/site-packages/six.py", line 216, in is_package
    return hasattr(self.__get_module(fullname), "__path__")
  File "lib/python3.6/site-packages/six.py", line 118, in __getattr__
    _module = self._resolve()
  File "lib/python3.6/site-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "lib/python3.6/site-packages/six.py", line 82, in _import_module
    __import__(name)
  File "<frozen importlib._bootstrap>", line 202, in _lock_unlock_module
  File "<frozen importlib._bootstrap>", line 98, in acquire
KeyboardInterrupt

Changing the import to from six.moves import http_client results in the import working fine. I'm on a RHEL6 machine, but using the Anaconda distribution (hence the modern GCC compiler). I tried the same on my mac and couldn't reproduce the issue.

This might seem esoteric, but I've traced this back from urllib3 which itself I traced from requests. The line that makes this import call is in urllibr3.exceptions. I'll submit a PR against urllib3 for this, but wanted to raise this here - I guess it is not expected behaviour, and worth sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant