improvement -> internet checking time

This commit is contained in:
Vinicius Moreira
2021-01-18 14:38:36 -03:00
parent 926ee65105
commit f3ac25fb0f
2 changed files with 4 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
import http.client as http_client
import socket
class InternetChecker:
@@ -10,11 +10,9 @@ class InternetChecker:
if self.offline:
return False
conn = http_client.HTTPConnection("www.google.com", timeout=5)
try:
conn.request("HEAD", "/")
conn.close()
socket.gethostbyname('google.com')
return True
except:
conn.close()
return False