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

[develop] VisiData occassionally gets stuck when importing requests #1808

Closed
anjakefala opened this issue Mar 18, 2023 · 2 comments
Closed

Comments

@anjakefala
Copy link
Collaborator

On develop branch, with Python v3.9, occassionally VisiData will fail to progress when loading from a url:

anja@kefala:git/visidata ‹develop*›$ vd https://visidata.org/usage.tsv
saul.pw/VisiData v2.12dev
loaded visidatarc

And you have to Ctrl+C to get the following stacktrace:

^CTraceback (most recent call last):
  File "/home/anja/anaconda3/envs/vd39/bin/vd", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/home/anja/git/visidata/bin/vd", line 6, in <module>
    visidata.main.vd_cli()
  File "/home/anja/git/visidata/visidata/main.py", line 372, in vd_cli
    rc = main_vd()
  File "/home/anja/git/visidata/visidata/main.py", line 294, in main_vd
    vs = vd.openSource(p, create=True, **opts) or vd.fail(f'could not open {p}')
  File "/home/anja/git/visidata/visidata/_open.py", line 145, in openSource
    vs = vd.openPath(Path(p), filetype=filetype)  # convert to Path and recurse
  File "/home/anja/git/visidata/visidata/_open.py", line 82, in openPath
    return openfunc(p, filetype=filetype)
  File "/home/anja/git/visidata/visidata/loaders/http.py", line 21, in openurl_http
    requests = vd.importExternal('requests')
  File "/home/anja/git/visidata/visidata/settings.py", line 459, in importExternal
    m = importlib.import_module(modname)
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/site-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/site-packages/urllib3/__init__.py", line 11, in <module>
    from . import exceptions
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/site-packages/urllib3/exceptions.py", line 3, in <module>
    from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/site-packages/urllib3/packages/six.py", line 192, in find_spec
    return spec_from_loader(fullname, self)
  File "<frozen importlib._bootstrap>", line 431, in spec_from_loader
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/site-packages/urllib3/packages/six.py", line 222, in is_package
    return hasattr(self.__get_module(fullname), "__path__")
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/site-packages/urllib3/packages/six.py", line 121, in __getattr__
    _module = self._resolve()
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/site-packages/urllib3/packages/six.py", line 118, in _resolve
    return _import_module(self.mod)
  File "/home/anja/anaconda3/envs/vd39/lib/python3.9/site-packages/urllib3/packages/six.py", line 87, in _import_module
    __import__(name)
  File "<frozen importlib._bootstrap>", line 211, in _lock_unlock_module
  File "<frozen importlib._bootstrap>", line 107, in acquire
KeyboardInterrupt

Our current hypothesis is that this is the relevant bug: python/cpython#91351

Conceivably, other loaders with importlib dependencies that also have dependencies might be affected. It is just currently reproducibly coming up for open_http.

@anjakefala anjakefala added the bug label Mar 18, 2023
@anjakefala
Copy link
Collaborator Author

anjakefala commented Mar 26, 2023

Update: I have seen it come up in Python v3.8 and v3.10.

@anjakefala anjakefala changed the title [develop v3.9] VisiData occassionally gets stuck when importing requests [develop] VisiData occassionally gets stuck when importing requests Mar 26, 2023
@anjakefala
Copy link
Collaborator Author

This seems to now be fixed! Seems to be the mixing of import and importExternal =)

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

No branches or pull requests

1 participant