Skip to content

Commit 12cec34

Browse files
committed
5.9.0 - Add ability to wait for N task iterations
1 parent c8edd16 commit 12cec34

File tree

12 files changed

+39
-15
lines changed

12 files changed

+39
-15
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
7878
- run: |
7979
mk python-release owner=vkottler \
80-
repo=runtimepy version=5.8.4
80+
repo=runtimepy version=5.9.0
8181
if: |
8282
matrix.python-version == '3.12'
8383
&& matrix.system == 'ubuntu-latest'

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Libre Embedded
3+
Copyright (c) 2025 Libre Embedded
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
=====================================
33
generator=datazen
44
version=3.1.4
5-
hash=f89c565370dd68d4215345aeab6feff4
5+
hash=3ef34104e5e034e1dbd47bb8020808b6
66
=====================================
77
-->
88

9-
# runtimepy ([5.8.4](https://pypi.org/project/runtimepy/))
9+
# runtimepy ([5.9.0](https://pypi.org/project/runtimepy/))
1010

1111
[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
1212
![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)

config

local/variables/package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
major: 5
3-
minor: 8
4-
patch: 4
3+
minor: 9
4+
patch: 0
55
entry: runtimepy

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"
44

55
[project]
66
name = "runtimepy"
7-
version = "5.8.4"
7+
version = "5.9.0"
88
description = "A framework for implementing Python services."
99
readme = "README.md"
1010
requires-python = ">=3.12"

runtimepy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =====================================
22
# generator=datazen
33
# version=3.1.4
4-
# hash=99838ab674af55409015e5abdd55fc6e
4+
# hash=809a612b14ec99a3d62dfdd4add8900e
55
# =====================================
66

77
"""
@@ -10,7 +10,7 @@
1010

1111
DESCRIPTION = "A framework for implementing Python services."
1212
PKG_NAME = "runtimepy"
13-
VERSION = "5.8.4"
13+
VERSION = "5.9.0"
1414

1515
# runtimepy-specific content.
1616
METRICS_NAME = "metrics"

runtimepy/net/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def hostname(ip_address: str) -> str:
159159
def address_str(name: str, fallback_host: str = "localhost", **kwargs) -> str:
160160
"""Get an IP address string for a given name."""
161161

162-
return _socket.getaddrinfo(
162+
return _socket.getaddrinfo( # type: ignore
163163
name if name else fallback_host, None, **kwargs
164164
)[0][4][0]
165165

runtimepy/primitives/int.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ def increment(self, amount: int = 1, timestamp_ns: int = None) -> int:
4040
self.set_value(new_val, timestamp_ns=timestamp_ns)
4141
return new_val
4242

43+
async def wait_for_increment(
44+
self, timeout: float, count: int = 1
45+
) -> EvalResult:
46+
"""Wait for this primitive to increment by a certain amount."""
47+
48+
return await self.wait_for_value(
49+
self.raw.value + count,
50+
timeout,
51+
operation=Operator.LESS_THAN_OR_EQUAL,
52+
)
53+
4354
async def wait_for_value(
4455
self,
4556
value: int | float,

runtimepy/task/basic/periodic.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ def disable(self) -> bool:
136136
self._enabled.clear()
137137
return result
138138

139+
async def wait_iterations(self, timeout: float, count: int = 1) -> bool:
140+
"""Wait for a task to complete a certain number of iterations."""
141+
142+
return bool(
143+
await self.metrics.dispatches.wait_for_increment(
144+
timeout, count=count
145+
)
146+
)
147+
139148
async def run(
140149
self, period_s: float = None, stop_sig: _asyncio.Event = None
141150
) -> None:

0 commit comments

Comments
 (0)