fast.com
fast.com copied to clipboard
Python3 + Linted + Switched to requests lib
Made the following changes:
- Converted code to
python3 - Linted code with
flake8 - Switched to the
requestslib fromurllibandurllib2
Hi Justin,
Impressive. Nice to know someone else uses the code. My remarks:
Incorrect speed
Your code IMHO gives incorrect results:
sander@Stream-13:~/git/python3-fastcom$ python3 fast_com_example_usage.py
Start speedtest against fast.com ...
Result: 144.6 Mbps
... Done
sander@Stream-13:~/git/python3-fastcom$ python3 fast_com_example_usage.py
Start speedtest against fast.com ...
Result: 147.3 Mbps
... Done
145 Mbps is impossible on my VDSL-connection. The site https://fast.com/ and my python2 tool report around 35 Mbps. So some kind of bug?
Python2 compatibility
I would like to keep the code python2 compatible, because I want it to be stay compatible with sabnzbd and NAS-devices which do have python2. After installing python-requests, this is the result of running with python2:
sander@Stream-13:~/git/python3-fastcom$ python2 fast_com_example_usage.py
Start speedtest against fast.com ...
('Result:', 141.0, 'Mbps')
... Done
Exception in thread Thread-2 (most likely raised during interpreter shutdown):Exception in thread Thread-3 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
Do you think that is solvable?
Hey,
I'll check to see about the speed bug. I'll also check about keeping python3 compatibility but I am less confident in that.
Thanks!
I found the bug and posted some suggestions for python 2-3 compatibility. With the above future imports the output should be the same both in python 2 and 3. @sanderjo I can't reproduce the exception you get on 2.7, for me the above runs fine on both 3.6 and 2.7.