Skip to content

Make download_to_drive purely async #4993

@aviadlevy

Description

@aviadlevy

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

The telegram.File.download_to_drive method is an async coroutine, but it performs synchronous file I/O (.write_bytes, shutil.copyfile).

These blocking calls can stall the asyncio event loop, especially with large files or heavy I/O load. This undermines the non-blocking promise of an async method and can hurt a bot's responsiveness.

Describe the solution you'd like

The method should be made fully asynchronous by replacing all synchronous file operations with non-blocking alternatives from the aiofiles library.

This change would make the entire file download process truly non-blocking.
I am happy to prepare and submit a Pull Request to implement this feature.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions