'How to check internet connection with a guarantee that the checking will not fail in the event that the Internet is connected but slow Mobile data

Welcome everyone I use this code to check that the internet is connected

import requests

def check():
    try:
        request = requests.get("http://www.example.com/", timeout=15)
        return True
    except (requests.ConnectionError,  requests.Timeout) as exception:
        return False

But sometimes the connection time ends with the presence of the Internet Because I download some movies or games and so it gives me a false report that the internet is not connected because of the slow internet

Is there a server or something that can check the internet if it is online or not Even if the internet is very slow?

Note that I use mobile data, not WiFi

have tried to change the operation failed Where I programmed a code when it finds that there is no internet if there are no directions to the server gives a value of false The operation also failed



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source