Do multiple attempts to avoid incomplete data in case of unstable network
(node_url, n_attempt=3)
| 595 | |
| 596 | |
| 597 | def _download_node_file(node_url, n_attempt=3): |
| 598 | """Do multiple attempts to avoid incomplete data in case |
| 599 | of unstable network""" |
| 600 | while n_attempt > 0: |
| 601 | try: |
| 602 | return io.BytesIO(urlopen(node_url).read()) |
| 603 | except IncompleteRead as e: |
| 604 | logger.warning( |
| 605 | 'Incomplete read while reading ' |
| 606 | 'from {} - {}'.format(node_url, e) |
| 607 | ) |
| 608 | n_attempt -= 1 |
| 609 | if n_attempt == 0: |
| 610 | raise e |
| 611 | |
| 612 | |
| 613 | def download_node_src(node_url, src_dir, args): |
no test coverage detected