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

tool_runner: avoid crash when urlopen raise HTTPError #11

Merged
merged 1 commit into from
Nov 5, 2023
Merged

tool_runner: avoid crash when urlopen raise HTTPError #11

merged 1 commit into from
Nov 5, 2023

Conversation

HerrCai0907
Copy link
Contributor

@HerrCai0907 HerrCai0907 commented May 19, 2023

I meet following error when using antlr4-tools. This patch wants to avoid crash when checking version failed due to network usse.

Traceback (most recent call last):
  File "/opt/homebrew/bin/antlr4", line 8, in <module>
    sys.exit(tool())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/antlr4_tool_runner.py", line 112, in tool
    args, version = get_version_arg(args)
                    ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/antlr4_tool_runner.py", line 105, in get_version_arg
    version = latest_version()
              ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/antlr4_tool_runner.py", line 14, in latest_version
    with urlopen(f"https://search.maven.org/solrsearch/select?q=a:antlr4-master+g:org.antlr") as response:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 504: Gateway Time-out
ninja: build stopped: subcommand failed.

@HerrCai0907
Copy link
Contributor Author

@parrt Could you kindly review this patch?

@jagalindo
Copy link

is there any workarrounds meanwhile devs take this into account?

@HerrCai0907
Copy link
Contributor Author

is there any workarrounds meanwhile devs take this into account?

clone this repo and use *.py directly

@parrt parrt added the enhancement New feature or request label Nov 5, 2023
@parrt parrt added this to the 0.2.1 milestone Nov 5, 2023
@parrt parrt merged commit 3733736 into antlr:master Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants