Let get_external_ip take a timeout.
This commit is contained in:
parent
53756662ad
commit
e8a0b0a050
1 changed files with 2 additions and 2 deletions
|
@ -23,9 +23,9 @@ class NetworkToolsException(Exception):
|
|||
class NoInternet(NetworkToolsException):
|
||||
pass
|
||||
|
||||
def get_external_ip() -> str:
|
||||
def get_external_ip(timeout=10) -> str:
|
||||
url = 'https://voussoir.net/whatsmyip'
|
||||
response = requests.get(url)
|
||||
response = requests.get(url, timeout=timeout)
|
||||
response.raise_for_status()
|
||||
ip = response.text.strip()
|
||||
return ip
|
||||
|
|
Loading…
Reference in a new issue