Skip to content

Commit

Permalink
Refator check_internet_connections (#283)
Browse files Browse the repository at this point in the history
* Refator check_internet_connections

* Bump to veta version

* Bump to stable version

---------

Co-authored-by: Sansa <[email protected]>
  • Loading branch information
igarridot and jsansaloni authored May 23, 2024
1 parent e905846 commit 1649771
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rele/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.15.1"
__version__ = "1.15.2"

try:
import django
Expand Down
9 changes: 6 additions & 3 deletions rele/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ def check_internet_connection(remote_server):
port = 80
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)

result = False
try:
sock.connect((remote_server, port))
return True
except socket.error:
return False
result = True
except (socket.error, socket.herror, socket.gaierror, socket.timeout) as error:
logger.exception("Check internet connection error", error)
finally:
sock.close()
return result


class Worker:
Expand Down

0 comments on commit 1649771

Please sign in to comment.