Attempt to catch MemoryError if possible
This commit is contained in:
parent
16054cc3bc
commit
3cb44f5630
16
speedtest.py
16
speedtest.py
|
@ -743,11 +743,17 @@ class HTTPUploaderData(object):
|
||||||
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
multiplier = int(round(int(self.length) / 36.0))
|
multiplier = int(round(int(self.length) / 36.0))
|
||||||
IO = BytesIO or StringIO
|
IO = BytesIO or StringIO
|
||||||
self._data = IO(
|
try:
|
||||||
('content1=%s' %
|
self._data = IO(
|
||||||
(chars * multiplier)[0:int(self.length) - 9]
|
('content1=%s' %
|
||||||
).encode()
|
(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
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
|
|
Loading…
Reference in New Issue