-
Notifications
You must be signed in to change notification settings - Fork 0
add functions to ali_sync.py and modify ali_sync.yaml #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…threads and limit the rate of synchronization data, and modify the corresponding configuration file
| FORCE_OVERRIDE: false | ||
|
|
||
| # 设置同步的并发线程数 | ||
| THREADS_NUM_FOR_SYNC: 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没看到在哪使用了这个配置
src/ali_sync.py
Outdated
| verb = 'PUT' | ||
| headers = { | ||
| 'Content-Length': resp_object.content_length, | ||
| 'Host': cnf['BAISHAN_ENDPOINT'][7:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 代表什么意思
用split或者其他字符串操作函数去掉http://或者https://
src/ali_sync.py
Outdated
| act_time = end_time - start_time | ||
| time_diff = expect_time - act_time | ||
| if time_diff > 0: | ||
| time.sleep(time_diff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里统计的是 读时间+写时间, 这样算出来的时间计算speed会比实际配置的要小
只统计读或者写时间就好
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个限速要放在while循环内, 在每次读1MB数据都需要统计限制下速度
src/ali_sync.py
Outdated
| time.sleep(time_diff) | ||
|
|
||
| cli.read_response() | ||
| cli.status == 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是啥意思
| cli.status == 200 | |
| cli.status == 200 |
src/ali_sync.py
Outdated
| return True | ||
|
|
||
|
|
||
| def upload_file(resp_object, result): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在哪里调用了upload_file 这个函数
src/ali_sync.py
Outdated
| start_time = time.time() | ||
| buf = resp_object.read(1024 * 1024) | ||
| end_time = time.time() | ||
| expect_time = send_size / cnf['SYNC_SPEED'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SYNC_SPEED是一个可选的配置项, 需要判断下是否设置
src/ali_sync.py
Outdated
|
|
||
| send_size = 0 | ||
| while True: | ||
| start_time = time.time() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
start_time设置为读取整个body的开始时间
src/ali_sync.py
Outdated
| cli.send_body(buf) | ||
| send_size += 1024 * 1024 | ||
|
|
||
| if buf == '': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放在while循环最开始
src/ali_sync.py
Outdated
| th_status['pipe_progress'] = (done_bytes, total_bytes) | ||
|
|
||
| file_object = result['file_object'] | ||
| upload_file(file_object, result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要替换的是418行的代码
add functions to ali_sync.py: configurable number of synchronization threads and limit the rate of synchronization data, and modify the corresponding configuration file