add functions to ali_sync.py and modify ali_sync.yaml#14
Open
Kelly123456789 wants to merge 5 commits intomasterfrom
Open
add functions to ali_sync.py and modify ali_sync.yaml#14Kelly123456789 wants to merge 5 commits intomasterfrom
Kelly123456789 wants to merge 5 commits intomasterfrom
Conversation
…threads and limit the rate of synchronization data, and modify the corresponding configuration file
pengsven
reviewed
Sep 3, 2020
| FORCE_OVERRIDE: false | ||
|
|
||
| # 设置同步的并发线程数 | ||
| THREADS_NUM_FOR_SYNC: 3 |
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.
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.
这里统计的是 读时间+写时间, 这样算出来的时间计算speed会比实际配置的要小
只统计读或者写时间就好
src/ali_sync.py
Outdated
| time.sleep(time_diff) | ||
|
|
||
| cli.read_response() | ||
| cli.status == 200 |
There was a problem hiding this comment.
这个是啥意思
Suggested change
| cli.status == 200 | |
| cli.status == 200 |
src/ali_sync.py
Outdated
| return True | ||
|
|
||
|
|
||
| def upload_file(resp_object, result): |
pengsven
reviewed
Sep 7, 2020
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'] |
src/ali_sync.py
Outdated
|
|
||
| send_size = 0 | ||
| while True: | ||
| start_time = time.time() |
src/ali_sync.py
Outdated
| cli.send_body(buf) | ||
| send_size += 1024 * 1024 | ||
|
|
||
| if buf == '': |
src/ali_sync.py
Outdated
| th_status['pipe_progress'] = (done_bytes, total_bytes) | ||
|
|
||
| file_object = result['file_object'] | ||
| upload_file(file_object, result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add functions to ali_sync.py: configurable number of synchronization threads and limit the rate of synchronization data, and modify the corresponding configuration file