romana / multi-ping

Python library to monitor one or many IP addresses via ICMP echo (ping) requests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception when none of the hostnames can be resolved

fjansson opened this issue · comments

If the list of host names contains only addresses that cannot be resolved, and ignore_lookup_errors is True, multi_ping fails.

#!/usr/bin/python                                                                                                                                                                                                                                                               
from multiping import multi_ping                                                                                                        
responses, no_responses = multi_ping(["no-such-host", "also-this-doesnt-exist"], timeout=2, retry=0, ignore_lookup_errors=True)         
Traceback (most recent call last):
  File "./test_multiping.py", line 4, in <module>
    responses, no_responses = multi_ping(["no-such-host", "also-this-doesnt-exist"], timeout=2, retry=0, ignore_lookup_errors=True)
  File "/usr/local/lib/python2.7/dist-packages/multiping/__init__.py", line 485, in multi_ping
    single_results, no_results = mp.receive(retry_timeout)
  File "/usr/local/lib/python2.7/dist-packages/multiping/__init__.py", line 376, in receive
    raise MultiPingError("No requests have been sent, yet.")
multiping.MultiPingError: No requests have been sent, yet.

The correct behavior would be to return the failing host names in the no_response array.