Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
storagedriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
4
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d9aafb6f
authored
Jan 05, 2021
by
Máhonfai Bálint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work around slow upload speed caused by httplib hardcoded small blocksize
parent
27f4364e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
disk.py
+18
-7
No files found.
disk.py
View file @
d9aafb6f
...
...
@@ -323,23 +323,34 @@ class Disk(object):
subprocess
.
check_output
(
cmdline
)
size
=
os
.
path
.
getsize
(
exported_path
)
percent
=
[
0
]
def
update_state
(
monitor
):
percent
=
monitor
.
bytes_read
*
100
/
size
new_
percent
=
monitor
.
bytes_read
*
100
/
size
if
task
.
is_aborted
():
raise
AbortException
()
task
.
update_state
(
task_id
=
parent_id
,
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
meta
=
{
'percent'
:
percent
}
)
if
new_percent
>
percent
[
0
]:
percent
[
0
]
=
new_percent
task
.
update_state
(
task_id
=
parent_id
,
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
meta
=
{
'percent'
:
percent
[
0
]}
)
with
open
(
exported_path
,
'rb'
)
as
exported_disk
:
try
:
e
=
MultipartEncoder
(
{
'data'
:
(
exported_name
+
'.'
+
disk_format
,
exported_disk
)}
exported_disk
,
'application/octet-stream'
)}
)
m
=
MultipartEncoderMonitor
(
e
,
update_state
)
# Force the read function to read more than 8192 bytes,
# which is a hardcoded value in httplib. This increases
# the upload speed. See:
# https://github.com/requests/toolbelt/issues/75
m
.
_read
=
m
.
read
m
.
read
=
lambda
_
:
m
.
_read
(
1024
*
1024
)
response
=
requests
.
post
(
upload_link
,
data
=
m
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment