🐛 Fixed GTK race condition in pipelines
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Callable
|
||||
from typing import Callable, Any
|
||||
|
||||
from gi.repository import Gio
|
||||
|
||||
@@ -26,8 +26,8 @@ class AsyncManager(Manager):
|
||||
Already scheduled Tasks will no longer be cancellable."""
|
||||
self.cancellable = Gio.Cancellable()
|
||||
|
||||
def run(self, game: Game, callback: Callable) -> None:
|
||||
task = Task.new(self, self.cancellable, self._task_callback, (callback,))
|
||||
def run(self, game: Game, callback: Callable[["Manager"], Any]) -> None:
|
||||
task = Task.new(None, self.cancellable, self._task_callback, (callback,))
|
||||
task.set_task_data((game,))
|
||||
task.run_in_thread(self._task_thread_func)
|
||||
|
||||
@@ -38,5 +38,5 @@ class AsyncManager(Manager):
|
||||
|
||||
def _task_callback(self, _source_object, _result, data):
|
||||
"""Method run after the async task is done"""
|
||||
_game, callback, *_rest = data
|
||||
callback, *_rest = data
|
||||
callback(self)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
from src import shared
|
||||
from src.game import Game
|
||||
from src.store.managers.file_manager import FileManager
|
||||
from src.store.managers.sgdb_manager import SGDBManager
|
||||
from src.store.managers.steam_api_manager import SteamAPIManager
|
||||
from src.store.managers.manager import Manager
|
||||
|
||||
|
||||
class DisplayManager(Manager):
|
||||
"""Manager in charge of adding a game to the UI"""
|
||||
|
||||
run_after = set((FileManager,))
|
||||
run_after = set((SteamAPIManager, SGDBManager))
|
||||
|
||||
def final_run(self, game: Game) -> None:
|
||||
# TODO decouple a game from its widget
|
||||
# TODO make the display manager async
|
||||
shared.win.games[game.game_id] = game
|
||||
game.update()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from abc import abstractmethod
|
||||
from typing import Callable
|
||||
from typing import Callable, Any
|
||||
|
||||
from src.game import Game
|
||||
|
||||
@@ -16,6 +16,10 @@ class Manager:
|
||||
errors: list[Exception]
|
||||
blocking: bool = True
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return type(self).__name__
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.errors = []
|
||||
@@ -38,7 +42,7 @@ class Manager:
|
||||
* May not raise exceptions, as they will be silently ignored
|
||||
"""
|
||||
|
||||
def run(self, game: Game, callback: Callable[["Manager"]]) -> None:
|
||||
def run(self, game: Game, callback: Callable[["Manager"], Any]) -> None:
|
||||
"""Pass the game through the manager.
|
||||
In charge of calling the final_run method."""
|
||||
self.final_run(game)
|
||||
|
||||
Reference in New Issue
Block a user