Skip to content

Commit

Permalink
Merge pull request #79 from inab/fixes
Browse files Browse the repository at this point in the history
Fixed hidden issues in co-routine handling
  • Loading branch information
jmfernandez authored Mar 19, 2024
2 parents a8ae887 + 8efa1e2 commit d6ff519
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions wfexs_backend/fetchers/internal/ftp_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import aioftp # type: ignore[import]


def asyncio_run(tasks: "Tuple[Coroutine[Any, Any, CT], ...]") -> "CT":
def asyncio_run(tasks: "Tuple[asyncio.Task[CT], ...]") -> "CT":
"""
Helper method which abstracts differences from
Python 3.7 and before about coroutines
Expand Down Expand Up @@ -359,12 +359,18 @@ def download_dir(
exclude_ext: "Sequence[str]" = [],
) -> "Sequence[Path]":
tasks = (
self.download_dir_async(download_from_dir, upload_to_dir, exclude_ext),
asyncio.create_task(
self.download_dir_async(download_from_dir, upload_to_dir, exclude_ext)
),
)
return asyncio_run(tasks)

def download_file(self, download_from_file: "str", upload_to_file: "str") -> "Path":
tasks = (self.download_file_async(download_from_file, upload_to_file),)
tasks = (
asyncio.create_task(
self.download_file_async(download_from_file, upload_to_file)
),
)
return asyncio_run(tasks)

def download(
Expand All @@ -373,7 +379,11 @@ def download(
upload_path: "str",
exclude_ext: "Sequence[str]" = [],
) -> "Union[Path, Sequence[Path]]":
tasks = (self.download_async(download_path, upload_path, exclude_ext),)
tasks = (
asyncio.create_task(
self.download_async(download_path, upload_path, exclude_ext)
),
)
return asyncio_run(tasks)

@staticmethod
Expand Down

0 comments on commit d6ff519

Please sign in to comment.