Skip to content

Commit aa3a9ed

Browse files
committed
⚡ Remove thread
1 parent 2401b4c commit aa3a9ed

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

src/repl_python_wakatime/hooks/wakatime.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
Refer `create-plugin <https://wakatime.com/help/creating-plugin>`_.
55
"""
66
import os
7-
from subprocess import run # nosec: B404
8-
from threading import Thread
7+
from subprocess import Popen # nosec: B404
98
from typing import Any, Callable
109

1110

12-
def send_wakatime_heartbeat(
11+
def wakatime_hook(
1312
project: str = "",
1413
category: str = "coding",
1514
plugin: str = "repl-python-wakatime",
@@ -41,7 +40,7 @@ def send_wakatime_heartbeat(
4140
from ..utils.project import get_project
4241

4342
project = get_project(filenames, detect_func)
44-
run( # nosec: B603 B607
43+
Popen( # nosec: B603 B607
4544
[
4645
"wakatime-cli",
4746
"--write",
@@ -51,20 +50,5 @@ def send_wakatime_heartbeat(
5150
"--entity=python",
5251
"--alternate-language=python",
5352
f"--project={project}",
54-
],
55-
stdout=open(os.devnull, "w"),
53+
]
5654
)
57-
58-
59-
def wakatime_hook(*args: Any, **kwargs: Any) -> None:
60-
"""Wakatime hook.
61-
62-
:param args:
63-
:type args: Any
64-
:param kwargs:
65-
:type kwargs: Any
66-
:rtype: None
67-
"""
68-
task = Thread(target=send_wakatime_heartbeat, args=args, kwargs=kwargs)
69-
task.daemon = True
70-
task.start()

0 commit comments

Comments
 (0)