Asynchronous python library to test connection speed, based on the speedtest project.
Project description
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
Release history Release notifications | RSS feed
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 details)
Built Distribution
File details
Details for the file aiotestspeed-0.0.1.tar.gz
.
File metadata
- Download URL: aiotestspeed-0.0.1.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d66023806763ba0c072711c569a29dbb56817dc6c9976bcb1decd9005877efbf |
|
MD5 | 7947c8edad1a6f8cb6b1ecb2aa5a818c |
|
BLAKE2b-256 | 11cd1965a0591758659535a97b95dd3cd482c3e0c2795eee3a21758c5eef860f |
File details
Details for the file aiotestspeed-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: aiotestspeed-0.0.1-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfbe2436d89c01cdec9dce2698117728525b7ad9f3ec58e8b8541181a5d07cb1 |
|
MD5 | 1cfc1651021b4144f98d50eeb5bb0822 |
|
BLAKE2b-256 | 0c97f185554fecfeb274126bd794a3515497053049dc3ce0df17e9fe12c81a2e |