diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a23c1112..ecd8aaaa 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -46,7 +46,7 @@ jobs: - run: mk python-sa-types - - run: mk docs version=5.17.10 + - run: mk docs version=5.17.11 if: | matrix.python-version == '3.14' && matrix.system == 'ubuntu-latest' @@ -78,7 +78,7 @@ jobs: - run: | mk python-release owner=libre-embedded \ - repo=runtimepy version=5.17.10 + repo=runtimepy version=5.17.11 if: | matrix.python-version == '3.14' && matrix.system == 'ubuntu-latest' diff --git a/README.md b/README.md index 6173aaa2..afeca00f 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ===================================== generator=datazen version=3.2.4 - hash=6cee789c808853d310d4825e0ae0b3ec + hash=75ff258728e82b4bd8f35db4e3783f6c ===================================== --> -# runtimepy ([5.17.10](https://pypi.org/project/runtimepy/)) +# runtimepy ([5.17.11](https://pypi.org/project/runtimepy/)) [![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/) ![Build Status](https://github.com/libre-embedded/runtimepy/workflows/Python%20Package/badge.svg) diff --git a/local/variables/package.yaml b/local/variables/package.yaml index 29d42a4d..467812f1 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,5 +1,5 @@ --- major: 5 minor: 17 -patch: 10 +patch: 11 entry: runtimepy diff --git a/pyproject.toml b/pyproject.toml index 9ae85dbd..064bf354 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "runtimepy" -version = "5.17.10" +version = "5.17.11" description = "A framework for implementing Python services." readme = "README.md" requires-python = ">=3.13" diff --git a/runtimepy/__init__.py b/runtimepy/__init__.py index efb37869..369436e2 100644 --- a/runtimepy/__init__.py +++ b/runtimepy/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen # version=3.2.4 -# hash=d2c7875a5ee32cef217be9d740dd74e2 +# hash=db9fbb88e8b1fdd667c54f44589d7d36 # ===================================== """ @@ -10,7 +10,7 @@ DESCRIPTION = "A framework for implementing Python services." PKG_NAME = "runtimepy" -VERSION = "5.17.10" +VERSION = "5.17.11" # runtimepy-specific content. METRICS_NAME = "metrics" diff --git a/runtimepy/mixins/logging.py b/runtimepy/mixins/logging.py index f9bbcebf..283731d7 100644 --- a/runtimepy/mixins/logging.py +++ b/runtimepy/mixins/logging.py @@ -102,14 +102,11 @@ def __init__(self, level: LogLevellike, path: Pathlike) -> None: self.level = LogLevel.normalize(level) self.path = path self.stream: Optional[Any] = None - self.ctime: int = 0 + self.path_size: int = 0 - async def get_ctime(self) -> int: + async def get_size(self) -> int: """Get ctime for this path.""" - - return round( # type: ignore - await aiofiles.os.path.getctime(self.path), - ) + return (await aiofiles.os.stat(self.path)).st_size # type: ignore async def handle_open(self) -> None: """Handle opening the stream.""" @@ -117,15 +114,18 @@ async def handle_open(self) -> None: if not self.stream and normalize(self.path).is_file(): self.stream = await aiofiles.open(self.path, mode="r") await self.stream.seek(0, io.SEEK_END) - self.ctime = await self.get_ctime() + self.path_size = await self.get_size() async def poll(self) -> AsyncIterator[tuple[LogLevel, str]]: """Poll stream contents.""" try: # Handle re-opening file if necessary. - if self.ctime != await self.get_ctime(): + curr = await self.get_size() + if curr < self.path_size: + yield LogLevel.WARNING, f"'{self.path}' truncated, re-opening." await self.close() + self.path_size = curr await self.handle_open() if self.stream: