Skip to content

Commit 8ea48ac

Browse files
authored
Add missing name params (#225)
1 parent 7c4ef78 commit 8ea48ac

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

aiomisc/service/carbon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def start(self) -> None:
5050

5151
set_client(client)
5252

53-
self._handle = PeriodicCallback(client.send)
53+
self._handle = PeriodicCallback(client.send, name="carbon-sender")
5454
self._handle.start(self.send_interval, loop=self.loop)
5555
log.info(
5656
"Periodic carbon metrics sender started. Send to %s://%s:%d with "

aiomisc/service/periodic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class PeriodicService(Service):
1414

1515
interval: Union[int, float]
1616
delay: Union[int, float] = 0
17+
name: str = "carbon-sender"
1718

1819
def __init__(self, *, name: Optional[str] = None, **kwargs: Any):
1920
super().__init__(**kwargs)
20-
self.periodic = PeriodicCallback(self.callback, name=name)
21+
self.periodic = PeriodicCallback(self.callback, name=self.name)
2122

2223
async def start(self) -> None:
2324
assert self.interval, f"Interval illegal interval {self.interval!r}"

aiomisc/service/profiler.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99

1010

1111
class Profiler(Service):
12-
profiler = None # type: cProfile.Profile
13-
periodic = None # type: PeriodicCallback
12+
profiler: cProfile.Profile
13+
periodic: PeriodicCallback
1414

15-
order = "cumulative" # type: str
15+
order: str = "cumulative"
1616

17-
path = None # type: str
18-
logger = None # type: logging.Logger
17+
path: Optional[str] = None
18+
logger: logging.Logger
1919

20-
interval = 10 # type: int
21-
top_results = 10 # type: int
22-
log = logging.getLogger(__name__) # type: logging.Logger
20+
interval: int = 10
21+
top_results: int = 10
22+
log: logging.Logger = logging.getLogger(__name__)
23+
24+
name: str = "profiler"
2325

2426
async def start(self) -> None:
2527
self.logger = self.log.getChild(str(id(self)))

aiomisc/service/sdwatchdog.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SDWatchdogService(Service):
3737
socket_addr: Optional[str]
3838
watchdog_interval: Optional[TimeoutType] = None
3939
watchdog_timer: PeriodicCallback
40+
name: str = "systemd-watchdog"
4041

4142
def __init__(
4243
self,
@@ -86,7 +87,9 @@ def disconnect(self) -> None:
8687
sock.close()
8788

8889
async def start(self) -> None:
89-
self.watchdog_timer = PeriodicCallback(self.send, "WATCHDOG=1")
90+
self.watchdog_timer = PeriodicCallback(
91+
self.send, "WATCHDOG=1", name=self.name,
92+
)
9093

9194
if self.is_connected and self.watchdog_interval is not None:
9295
if self.watchdog_interval != WATCHDOG_INTERVAL:

aiomisc/service/tracer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class MemoryTracer(Service):
2828
top_results: int = 20
2929

3030
group_by: GroupBy = GroupBy.lineno
31+
name: str = "memory-tracer"
3132

3233
STAT_FORMAT: str = (
3334
"%(count)8s | "
@@ -41,7 +42,7 @@ async def start(self) -> None:
4142
log.warning("Start memory tracer")
4243
tracemalloc.start()
4344

44-
self._tracer = PeriodicCallback(self.show_stats)
45+
self._tracer = PeriodicCallback(self.show_stats, name=self.name)
4546
self._log = log.getChild(str(id(self)))
4647

4748
self._snapshot_on_start = self.take_snapshot()

0 commit comments

Comments
 (0)