Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sivel/speedtest-cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2017-05-02 19:08:22 +0300
committerMatt Martz <matt@sivel.net>2017-11-23 19:14:35 +0300
commitfe864f6dce881c4592a952df8db59745eff3fd7d (patch)
treea3449e3cd6020a133ffcb98746b3739490ab2aaa
parent10b3b09f02bfd9636af4a10b84abcd3c26035949 (diff)
Use vendored create_connection when socket doesn't have it, or socket.create_connection is too old
-rwxr-xr-xspeedtest.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/speedtest.py b/speedtest.py
index 115b2f8..ad7dbb7 100755
--- a/speedtest.py
+++ b/speedtest.py
@@ -373,18 +373,20 @@ class SpeedtestHTTPConnection(HTTPConnection):
self._context = context
self.timeout = timeout
- try:
- self._create_connection = socket.create_connection
- except AttributeError:
- self._create_connection = create_connection
-
def connect(self):
"""Connect to the host and port specified in __init__."""
- self.sock = self._create_connection(
- (self.host, self.port),
- self.timeout,
- self.source_address
- )
+ try:
+ self.sock = socket.create_connection(
+ (self.host, self.port),
+ self.timeout,
+ self.source_address
+ )
+ except (AttributeError, TypeError):
+ self.sock = create_connection(
+ (self.host, self.port),
+ self.timeout,
+ self.source_address
+ )
if HTTPSConnection: