From 79f83e4ab4bd0f23b1dd9672d06f0ef69607ea19 Mon Sep 17 00:00:00 2001 From: Lele Long Date: Wed, 12 Feb 2014 17:26:58 +0800 Subject: [PATCH] Add timeout for socket --- speedtest_cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/speedtest_cli.py b/speedtest_cli.py index 0d40be5..ed7b1a7 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -465,18 +465,22 @@ def speedtest(): parser.add_argument('--version', action='store_true', help='Show the version number and exit') parser.add_argument('--no-upload', action='store_true', help='no upload speed test') + parser.add_argument('--timeout', type=int, default=30, help='socket timeout in seconds(default to 30)') options = parser.parse_args() if isinstance(options, tuple): args = options[0] else: args = options + del options # Print the version and exit if args.version: version() + socket.setdefaulttimeout(args.timeout) + # If specified bind to a specific IP address if args.source: source = args.source