Merge pull request 'API: async signal integration migration' (#1762) from hsjobeki/clan-core:hsjobeki-main into main

This commit is contained in:
clan-bot
2024-07-16 09:37:25 +00:00
4 changed files with 15 additions and 12 deletions

View File

@@ -29,8 +29,7 @@ class ImplFunc(GObject.Object, Generic[P, B]):
"returns": (GObject.SignalFlags.RUN_FIRST, None, [GResult]),
}
def returns(self, result: B) -> None:
method_name = self.__class__.__name__
def returns(self, method_name: str, result: B) -> None:
if self.op_key is None:
raise ValueError(f"op_key is not set for the function {method_name}")
self.emit("returns", GResult(result, method_name, self.op_key))
@@ -109,7 +108,7 @@ class GObjApi:
def async_run(self, *args: Any, **kwargs: dict[str, Any]) -> bool:
assert plain_method is not None
result = plain_method(*args, **kwargs)
self.returns(result)
self.returns(method_name=name, result=result)
return GLib.SOURCE_REMOVE
return cast(type[ImplFunc], GenericFnRuntime)

View File

@@ -116,7 +116,6 @@ class WebExecutor(GObject.Object):
result = dict()
result["result"] = dataclass_to_dict(data.result)
result["op_key"] = data.op_key
serialized = json.dumps(result, indent=4)
log.debug(f"Result: {serialized}")
# Use idle_add to queue the response call to js on the main GTK thread