Skip to content

Application.run_async leaking memory #1057

Open
@Chris3606

Description

@Chris3606

Upon running the example code in examples\prompts\asyncio-prompt.py, I noticed the memory usage climbed rapidly and consistently on my machine -- simply leaving the application sit without doing anything with it would have python.exe using a gigabyte or more of RAM in a few minutes. This was run on a Windows 10 machine running Python 3.8.1.

A bit of investigation later, it appears that the issue may be the underlying app.run_async call is adding thousands of tasks to event loop during its execution. Modifying line 30 of the asyncio-prompt.py example file from its current print statement to print(f'Tasks: {len(asyncio.all_tasks())}') shows that the number of active tasks in the event loop grows very quickly during execution:
image

This is only an issue with the current master branch version -- it does not occur in prompt-toolkit 3.0.2 from pip, but I figured the issue might still be of use to report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions