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

Some exceptions are still thrown even if EXCEPTIONS mode is disabled #74

Closed
basilevs opened this issue Oct 10, 2023 · 2 comments
Closed

Comments

@basilevs
Copy link

Test steps

  • On MacOS ping your WiFi router in a loop
  • Disconnect WiFi

Expected result:

False

Actual result

Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/vasiligulevich/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/Users/vasiligulevich/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/Users/vasiligulevich/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/Users/vasiligulevich/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/Users/vasiligulevich/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Users/vasiligulevich/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/Users/vasiligulevich/git/private_scripts/monitor_network.py", line 31, in <module>
    if check_host('192.168.1.1'):
  File "/Users/vasiligulevich/git/private_scripts/monitor_network.py", line 18, in check_host
    result = ping(host)
  File "/Users/vasiligulevich/Library/Python/3.9/lib/python/site-packages/ping3/__init__.py", line 83, in wrapper
    func_return = func(*args, **kwargs)
  File "/Users/vasiligulevich/Library/Python/3.9/lib/python/site-packages/ping3/__init__.py", line 310, in ping
    send_one_ping(sock=sock, dest_addr=dest_addr, icmp_id=icmp_id, seq=seq, size=size)
  File "/Users/vasiligulevich/Library/Python/3.9/lib/python/site-packages/ping3/__init__.py", line 83, in wrapper
    func_return = func(*args, **kwargs)
  File "/Users/vasiligulevich/Library/Python/3.9/lib/python/site-packages/ping3/__init__.py", line 176, in send_one_ping
    sock.sendto(packet, (dest_addr, 0))  # addr = (ip, port). Port is 0 respectively the OS default behavior will be used.
OSError: [Errno 65] No route to host
@kyan001
Copy link
Owner

kyan001 commented Oct 11, 2023

Thanks for you feedback.

The EXCEPTION switch only affects PingError exceptions, such as TTL expired, Destination Unreachable, etc. These errors are usually reported by the packets that are received, except for Timeout. The OSError exceptions, such as permission denied or WIFI disconnected, should be handled by the ping3 user, not by ping3 itself.

I hope my explanation has clarified the situation and resolved your concern. If you agree with me, I will close this issue as solved. However, if you still have a different opinion or any questions, please feel free to discuss with me.

@basilevs
Copy link
Author

I use ping for connectivity check. It feels strange, that I get inconsistent behavior between a routing failure on a remote host and on local host. I expect a library to hide the low level details from me, when I do connectivity check (unlike exceptions mode, where details are expected and requested).

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

2 participants