fast.com icon indicating copy to clipboard operation
fast.com copied to clipboard

Python3 + Linted + Switched to requests lib

Open justinaustin opened this issue 8 years ago • 3 comments

Made the following changes:

  • Converted code to python3
  • Linted code with flake8
  • Switched to the requests lib from urllib and urllib2

justinaustin avatar Jul 23 '17 03:07 justinaustin

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?

sanderjo avatar Jul 23 '17 06:07 sanderjo

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!

justinaustin avatar Jul 23 '17 14:07 justinaustin

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.

adeak avatar Mar 30 '18 17:03 adeak