Skip to content

Commit 8b8ac1b

Browse files
authored
fix(smartpause): remove duplicated call on x11 (slgobinath#772)
* fix(utility): add types to start_thread and execute_main_thread * fix(smartpause): remove duplicated call on x11
1 parent 784f48d commit 8b8ac1b

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

safeeyes/plugins/smartpause/x11.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def start_monitor(
6161
if not self._is_active():
6262
# If SmartPause is already started, do not start it again
6363
self._set_active(True)
64-
utility.start_thread(self._start_idle_monitor)
6564
utility.start_thread(
6665
self._start_idle_monitor,
6766
on_idle=on_idle,

safeeyes/utility.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,29 @@ def get_resource_path(resource_name):
9595
return resource_location
9696

9797

98-
def start_thread(target_function, **args):
98+
P1 = typing.ParamSpec("P1")
99+
100+
101+
def start_thread(
102+
target_function: typing.Callable[P1, None], *args: P1.args, **kwargs: P1.kwargs
103+
) -> None:
99104
"""Execute the function in a separate thread."""
100105
thread = threading.Thread(
101106
target=target_function,
102107
name=f"WorkThread {target_function.__qualname__}",
103108
daemon=False,
104-
kwargs=args,
109+
args=args,
110+
kwargs=kwargs,
105111
)
106112
thread.start()
107113

108114

109-
def execute_main_thread(target_function, *args, **kwargs):
115+
P2 = typing.ParamSpec("P2")
116+
117+
118+
def execute_main_thread(
119+
target_function: typing.Callable[P2, None], *args: P2.args, **kwargs: P2.kwargs
120+
) -> None:
110121
"""Execute the given function in main thread."""
111122
GLib.idle_add(lambda: target_function(*args, **kwargs))
112123

0 commit comments

Comments
 (0)