Use BytesIO on py3 in HTTPUploaderData
This commit is contained in:
parent
59880107a7
commit
d41cfc0cb1
10
speedtest.py
10
speedtest.py
|
@ -491,8 +491,12 @@ class HTTPUploaderData(object):
|
||||||
def _create_data(self):
|
def _create_data(self):
|
||||||
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
multiplier = int(round(int(self.length) / 36.0))
|
multiplier = int(round(int(self.length) / 36.0))
|
||||||
self._data = StringIO('content1=%s' %
|
IO = BytesIO or StringIO
|
||||||
(chars * multiplier)[0:int(self.length) - 9])
|
self._data = IO(
|
||||||
|
('content1=%s' %
|
||||||
|
(chars * multiplier)[0:int(self.length) - 9]
|
||||||
|
).encode()
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
|
@ -503,7 +507,7 @@ class HTTPUploaderData(object):
|
||||||
def read(self, n=10240):
|
def read(self, n=10240):
|
||||||
if ((timeit.default_timer() - self.start) <= self.timeout and
|
if ((timeit.default_timer() - self.start) <= self.timeout and
|
||||||
not SHUTDOWN_EVENT.isSet()):
|
not SHUTDOWN_EVENT.isSet()):
|
||||||
chunk = self.data.read(n).encode()
|
chunk = self.data.read(n)
|
||||||
self.total.append(len(chunk))
|
self.total.append(len(chunk))
|
||||||
return chunk
|
return chunk
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue