Flow-Launcher / Flow-Launcher/Flow.Launcher
Persist data in Python plugins per query
- Dominant language
- C#
- Stars
- 15.6k
- Forks
- 644
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 4
Description
**Is your feature request related to a problem? Please describe.**
Is it possible to persist data in a Python plugin class?
**Describe the solution you'd like**
I have created a Python plugin for FlowLauncher using `flox`. This plugin has expensive function that takes seconds to complete, and ideally I would like for this function to be executed once (at startup) and never again. This is due to the plugin re-running this function on every `query` function call, which causes users having to wait each time they type something. I have been trying to re-structure the code, to avoid the function being run every time, but haven't managed it. So I'm thinking, am I doing something wrong or is this the default behaviour of how FlowLauncher works? If so, is this something the FlowLauncher team/contributors are planning to solve or is there a workaround?
**Describe alternatives you've considered**
Continue calling the expensive function on every query, although it will require users to wait 1-3 seconds every time they type.
**Additional context**
In case necessary, the plugin I'm referring to is linked [here](https://github.com/marcelmiro/Flow.Launcher.Plugin.AudioEnvironments/blob/main/plugin/audio_environments.py#L81), and the expensive function is called `list_devices`. I also tried to solve this by using `flowlauncher`.
This is my first PR so please let me know if this is not the conventional way of requesting a feature or asking to know if I'm doing something wrong.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.