🚧 using closures to pass data to Tasks
This commit is contained in:
@@ -66,13 +66,14 @@ class Importer:
|
|||||||
for source in self.sources:
|
for source in self.sources:
|
||||||
self.n_source_tasks_created += 1
|
self.n_source_tasks_created += 1
|
||||||
logging.debug("Importing games from source %s", source.id)
|
logging.debug("Importing games from source %s", source.id)
|
||||||
task = Gio.Task(None, None, self.source_task_callback, (source,))
|
|
||||||
task.set_task_data((source,))
|
|
||||||
tasks.add(task)
|
|
||||||
|
|
||||||
# Start all tasks
|
def closure(task, obj, _data, cancellable):
|
||||||
for task in tasks:
|
self.source_task_thread_func(task, obj, (source,), cancellable)
|
||||||
task.run_in_thread(self.source_task_thread_func)
|
|
||||||
|
task = Gio.Task.new(None, None, self.source_task_callback, (source,))
|
||||||
|
self.n_sgdb_tasks_created += 1
|
||||||
|
task.run_in_thread(closure)
|
||||||
|
tasks.add(task)
|
||||||
|
|
||||||
def create_dialog(self):
|
def create_dialog(self):
|
||||||
"""Create the import dialog"""
|
"""Create the import dialog"""
|
||||||
@@ -133,11 +134,14 @@ class Importer:
|
|||||||
|
|
||||||
# Start sgdb lookup for game
|
# Start sgdb lookup for game
|
||||||
# HACK move to its own manager
|
# HACK move to its own manager
|
||||||
task = Gio.Task(
|
|
||||||
|
def closure(task, obj, _data, cancellable):
|
||||||
|
self.sgdb_task_thread_func(task, obj, (game,), cancellable)
|
||||||
|
|
||||||
|
task = Gio.Task.new(
|
||||||
None, self.sgdb_cancellable, self.sgdb_task_callback, (game,)
|
None, self.sgdb_cancellable, self.sgdb_task_callback, (game,)
|
||||||
)
|
)
|
||||||
task.set_task_data((game,))
|
task.run_in_thread(closure)
|
||||||
task.run_in_thread(self.sgdb_task_thread_func)
|
|
||||||
|
|
||||||
def source_task_callback(self, _obj, _result, data):
|
def source_task_callback(self, _obj, _result, data):
|
||||||
"""Source import callback"""
|
"""Source import callback"""
|
||||||
|
|||||||
Reference in New Issue
Block a user