mirror of
https://github.com/sivel/speedtest-cli.git
synced 2026-01-05 03:20:07 +01:00
Attempt to catch MemoryError if possible
This commit is contained in:
16
speedtest.py
16
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):
|
||||
|
||||
Reference in New Issue
Block a user