From 3362e03c5f3389f8b741ed5732e3f698a7d56d80 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Thu, 8 Dec 2022 21:55:57 +0100 Subject: [PATCH] Fix problems --- .pre-commit-config.yaml | 6 +++--- src/app/services/fl_downloader.py | 18 ++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 58649c0..1356a4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,16 +2,16 @@ exclude: 'docs|node_modules|migrations|.git|.tox' repos: - repo: https://github.com/ambv/black - rev: 22.3.0 + rev: 22.10.0 hooks: - id: black - language_version: python3.9 + language_version: python3.11 - repo: https://github.com/pycqa/isort rev: 5.10.1 hooks: - id: isort - repo: https://github.com/csachs/pyproject-flake8 - rev: v0.0.1a3 + rev: v6.0.0 hooks: - id: pyproject-flake8 additional_dependencies: [ diff --git a/src/app/services/fl_downloader.py b/src/app/services/fl_downloader.py index 80aa24d..1e065fb 100644 --- a/src/app/services/fl_downloader.py +++ b/src/app/services/fl_downloader.py @@ -55,7 +55,7 @@ class FLDownloader(BaseDownloader): return await self.get_filename() - @async_retry(httpx.ReadTimeout, times=5, delay=10) + @async_retry(NotSuccess, times=5, delay=10) async def _download_from_source( self, source_config: SourceConfig, file_type: Optional[str] = None ) -> tuple[httpx.AsyncClient, httpx.Response, bool]: @@ -104,10 +104,14 @@ class FLDownloader(BaseDownloader): raise ReceivedHTML() return client, response, "application/zip" in content_type - except (asyncio.CancelledError, NotSuccess, ReceivedHTML): + except (asyncio.CancelledError, httpx.HTTPError, NotSuccess, ReceivedHTML) as e: await response.aclose() await client.aclose() - raise + + if isinstance(e, httpx.HTTPError): + raise NotSuccess(str(e)) + else: + raise e @classmethod async def _close_other_done( @@ -154,13 +158,7 @@ class FLDownloader(BaseDownloader): ) return data - except ( - NotSuccess, - ReceivedHTML, - ConvertationError, - FileNotFoundError, - ValueError, - ): + except *: continue tasks_ = pending