has_network

has_network(hostname='one.one.one.one', timeout=3)[source]

Detect if the current environment has a network connection.

Create a socket connection to the hostname and check if the connection is successful.

Parameters
  • hostname (str) – The hostname to ping. Defaults to “one.one.one.one”.

  • timeout (Number) – Timeout in seconds for the fallback GET request.

Returns

True if the current environment has a network connection,

False otherwise.

Return type

bool