mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 05:14:16 +02:00
improvement: suggestions are now retrieved asynchronously
This commit is contained in:
@@ -5,8 +5,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
## [0.5.1]
|
## [0.5.1]
|
||||||
|
### Improvements:
|
||||||
|
- suggestions are now retrieved asynchronously. Response time takes 45% less.
|
||||||
### Fixes:
|
### Fixes:
|
||||||
- flatpak dependency
|
- [flatpak dependency](https://github.com/vinifmor/fpakman/issues/36)
|
||||||
|
|
||||||
## [0.5.0] - 2019-08-06
|
## [0.5.0] - 2019-08-06
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
|
from threading import Thread
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
|
|
||||||
from fpakman.core.disk import DiskCacheLoader, DiskCacheLoaderFactory
|
from fpakman.core.disk import DiskCacheLoader, DiskCacheLoaderFactory
|
||||||
@@ -290,10 +291,22 @@ class GenericApplicationManager(ApplicationManager):
|
|||||||
|
|
||||||
return warnings
|
return warnings
|
||||||
|
|
||||||
|
def _fill_suggestions(self, suggestions: list, man: ApplicationManager):
|
||||||
|
if self._is_enabled(man):
|
||||||
|
suggestions.extend(man.list_suggestions(6))
|
||||||
|
|
||||||
def list_suggestions(self, limit: int) -> List[Application]:
|
def list_suggestions(self, limit: int) -> List[Application]:
|
||||||
|
ti = time.time()
|
||||||
if self.managers:
|
if self.managers:
|
||||||
suggestions = []
|
suggestions, threads = [], []
|
||||||
for man in self.managers:
|
for man in self.managers:
|
||||||
if self._is_enabled(man):
|
t = Thread(target=self._fill_suggestions, args=(suggestions, man))
|
||||||
suggestions.extend(man.list_suggestions(6))
|
t.start()
|
||||||
|
threads.append(t)
|
||||||
|
|
||||||
|
for t in threads:
|
||||||
|
t.join()
|
||||||
|
|
||||||
|
tf = time.time() - ti
|
||||||
|
print(tf)
|
||||||
return suggestions
|
return suggestions
|
||||||
|
|||||||
Reference in New Issue
Block a user