diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-07-27 19:03:29 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-07-27 19:03:29 -0300 |
commit | 8eeb395a73a9a3c18b9c7659eedd5cf3927257d2 (patch) | |
tree | f5e16388e8548577e1909c7c97d7412dc618a387 | |
parent | 31cf445ff5b5c9161b782ac42742ba6c76bf1e49 (diff) | |
download | finder-8eeb395a73a9a3c18b9c7659eedd5cf3927257d2.tar.gz finder-8eeb395a73a9a3c18b9c7659eedd5cf3927257d2.tar.bz2 |
Fix: plugin: opener: searcher: use asyncio instead of threading, and fix the background process
-rw-r--r-- | packages/finder/plugin/searcher/file/name.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/finder/plugin/searcher/file/name.py b/packages/finder/plugin/searcher/file/name.py index caf2a63..0a9567c 100644 --- a/packages/finder/plugin/searcher/file/name.py +++ b/packages/finder/plugin/searcher/file/name.py @@ -21,8 +21,8 @@ import os import re import json +import asyncio -from threading import Thread from platformdirs import user_cache_dir class FinderPluginFileNameSearcher(): @@ -49,7 +49,8 @@ class FinderPluginFileNameSearcher(): self.items = json.load(f) # Then update the folder list in the background - walker = Thread(target=self.walker, name='Walker for ' + self.path) + async with asyncio.TaskGroup() as tg: + walker = tg.create_task(self.walker()) return self.items @@ -72,9 +73,10 @@ class FinderPluginFileNameSearcher(): def has_cache(self): pass - def walker(self): + async def walker(self): ignore_folders = [ '.git', '__pycache__' ] ignore_files = [ '.gitignore', '.gitattributes', '.gitmodules' ] + items = [] for parent, dirs, files in os.walk(self.path): # Do not traverse some folders @@ -101,4 +103,6 @@ class FinderPluginFileNameSearcher(): if file.startswith('.'): continue - self.items.append(os.path.join(parent, file)) + items.append(os.path.join(parent, file)) + + self.items = items |