Closed vicalloy closed 1 year ago
Thanks! The fix makes sense to me. I'm merging it, because it does fix the issue, and it's quite trivial. But long term, I have to think of a better solution.
So, the problem is that all filters have a cache within them, and if we do global_filter & filter_that_references_our_prompt_session
then the global filter will hold a reference to our filter in the cache, which will hold a reference to the prompt session.
The cache is really important for performance, so it's quite tricky. I'm not sure what alternative we have.
Reference: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1688
I updated to the latest
python-prompt-toolkit
and found that it still has memory leaks. If a filter cached by a global filter function, such asdef is_done()
, the filter cannot be freed. Filter operations should be very careful to avoid using global filters as the first filter.Unresolved bug: If I called
await session.prompt_async()
onePromptSession
is not freed.