(self, bucket, key, filename, extra_args, callback)
| 837 | ) |
| 838 | |
| 839 | def _get_object(self, bucket, key, filename, extra_args, callback): |
| 840 | # precondition: num_download_attempts > 0 |
| 841 | max_attempts = self._config.num_download_attempts |
| 842 | last_exception = None |
| 843 | for i in range(max_attempts): |
| 844 | try: |
| 845 | return self._do_get_object( |
| 846 | bucket, key, filename, extra_args, callback |
| 847 | ) |
| 848 | except ( |
| 849 | socket.timeout, |
| 850 | OSError, |
| 851 | ReadTimeoutError, |
| 852 | IncompleteReadError, |
| 853 | ) as e: |
| 854 | # TODO: we need a way to reset the callback if the |
| 855 | # download failed. |
| 856 | logger.debug( |
| 857 | "Retrying exception caught (%s), " |
| 858 | "retrying request, (attempt %s / %s)", |
| 859 | e, |
| 860 | i, |
| 861 | max_attempts, |
| 862 | exc_info=True, |
| 863 | ) |
| 864 | last_exception = e |
| 865 | continue |
| 866 | raise RetriesExceededError(last_exception) |
| 867 | |
| 868 | def _do_get_object(self, bucket, key, filename, extra_args, callback): |
| 869 | response = self._client.get_object( |
no test coverage detected