Skip to main content

Asynchronous python library to test connection speed, based on the speedtest project.

Project description


AIO Speedtest

AIO Speedtest is a library written in Python to perform speed tests asynchronously and programmatically.


This project was made based on the existing Speedtest from which we shared several code snippets, what I did were few modifications to work asynchronously.

Basic Usage

import asyncio
from aiotestspeed.aio import Speedtest

units = ('bit', 1)

async def main():
    s: Speedtest = await Speedtest()
    await s.get_best_server()
    await s.download()
    await s.upload()
    print('Ping: %s ms\nDownload: %0.2f M%s/s\nUpload: %0.2f M%s/s' %
          (s.results.ping,
          (s.results.download / 1000.0 / 1000.0) / units[1],
          units[0],
          (s.results.upload / 1000.0 / 1000.0) / units[1],
          units[0]))

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
class Speedtest(aiobject):

    async def __init__(self, config=None, source_address=None, timeout=10, secure=False):
        ...

    @property
    async def best(self) -> dict:
        ...

    async def get_config(self) -> dict:
        """Download the speedtest.net configuration and return only the data
        we are interested in
        """
        ...

    async def get_servers(self, servers: list = None, exclude: list = None) -> list:
        """Retrieve a the list of speedtest.net servers, optionally filtered
        to servers matching those specified in the ``servers`` argument
        """
        ...

    async def set_mini_server(self, server: str) -> list:
        """Instead of querying for a list of servers, set a link to a
        speedtest mini server
        """
        ...

    async def get_closest_servers(self, limit: int = 5) -> None:
        """Limit servers to the closest speedtest.net servers based on
        geographic distance.
        """
        ...

    async def get_best_server(self, servers=None) -> dict:
        """Perform a speedtest.net "ping" to determine which speedtest.net
        server has the lowest latency.

        Args:
            servers ([type], optional): [description]. Defaults to None.

        Raises:
            SpeedtestBestServerFailure: [description]

        Returns:
            dict: [description]
        """
        ...

    async def download(self, callback=do_nothing) -> int:
        """Test download speed against speedtest.net

        Args:
            callback ([type], optional): [description]. Defaults to do_nothing.

        Returns:
            int: [description]
        """
        ...

    async def upload(self, callback=do_nothing, pre_allocate: bool = True) -> int:
        """Test upload speed against speedtest.net

        Args:
            callback ([type], optional): [description]. Defaults to do_nothing.
            pre_allocate (bool, optional): [description]. Defaults to True.

        Returns:
            int: [description]
        """
        ...

Changelog

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiotestspeed-0.0.1.tar.gz (16.7 kB view hashes)

Uploaded source

Built Distribution

aiotestspeed-0.0.1-py3-none-any.whl (20.2 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page