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-10-16 17:26:47 +0300
committerMatt Martz <matt@sivel.net>2017-11-23 19:15:09 +0300
commit3cb44f563023c3db164eba6d905a1c6617324ae1 (patch)
tree0680f8ea9040e518f235cef6965e2b1c09eaa175 /speedtest.py
parent16054cc3bc4cbb389b35f4b6ef74c2c7cf5a80aa (diff)
Attempt to catch MemoryError if possible
Diffstat (limited to 'speedtest.py')
-rwxr-xr-xspeedtest.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/speedtest.py b/speedtest.py
index 7fa6590..bbc376b 100755
--- a/speedtest.py
+++ b/speedtest.py
@@ -743,11 +743,17 @@ class HTTPUploaderData(object):
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
multiplier = int(round(int(self.length) / 36.0))
IO = BytesIO or StringIO
- self._data = IO(
- ('content1=%s' %
- (chars * multiplier)[0:int(self.length) - 9]
- ).encode()
- )
+ try:
+ self._data = IO(
+ ('content1=%s' %
+ (chars * multiplier)[0:int(self.length) - 9]
+ ).encode()
+ )
+ except MemoryError:
+ raise SpeedtestCLIError(
+ 'Insufficient memory to pre-allocate upload data. Please '
+ 'use --no-pre-allocate'
+ )
@property
def data(self):