Fix problems

This commit is contained in:
2022-12-08 21:55:57 +01:00
parent 1f369aa8d7
commit 3362e03c5f
2 changed files with 11 additions and 13 deletions

View File

@@ -2,16 +2,16 @@ exclude: 'docs|node_modules|migrations|.git|.tox'
repos: repos:
- repo: https://github.com/ambv/black - repo: https://github.com/ambv/black
rev: 22.3.0 rev: 22.10.0
hooks: hooks:
- id: black - id: black
language_version: python3.9 language_version: python3.11
- repo: https://github.com/pycqa/isort - repo: https://github.com/pycqa/isort
rev: 5.10.1 rev: 5.10.1
hooks: hooks:
- id: isort - id: isort
- repo: https://github.com/csachs/pyproject-flake8 - repo: https://github.com/csachs/pyproject-flake8
rev: v0.0.1a3 rev: v6.0.0
hooks: hooks:
- id: pyproject-flake8 - id: pyproject-flake8
additional_dependencies: [ additional_dependencies: [

View File

@@ -55,7 +55,7 @@ class FLDownloader(BaseDownloader):
return await self.get_filename() 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( async def _download_from_source(
self, source_config: SourceConfig, file_type: Optional[str] = None self, source_config: SourceConfig, file_type: Optional[str] = None
) -> tuple[httpx.AsyncClient, httpx.Response, bool]: ) -> tuple[httpx.AsyncClient, httpx.Response, bool]:
@@ -104,10 +104,14 @@ class FLDownloader(BaseDownloader):
raise ReceivedHTML() raise ReceivedHTML()
return client, response, "application/zip" in content_type 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 response.aclose()
await client.aclose() await client.aclose()
raise
if isinstance(e, httpx.HTTPError):
raise NotSuccess(str(e))
else:
raise e
@classmethod @classmethod
async def _close_other_done( async def _close_other_done(
@@ -154,13 +158,7 @@ class FLDownloader(BaseDownloader):
) )
return data return data
except ( except *:
NotSuccess,
ReceivedHTML,
ConvertationError,
FileNotFoundError,
ValueError,
):
continue continue
tasks_ = pending tasks_ = pending