Skip to content

Commit 1d71706

Browse files
author
michaelyaakoby
authored
Merge pull request #27 from SolarEdgeTech/michael/issues
Fix issues 20, 22, 23, 24, 25 and 28
2 parents 09d69bb + 6418662 commit 1d71706

14 files changed

+243
-71
lines changed

.github/workflows/python_package_build.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,34 @@ jobs:
1212
container:
1313
image: matanrubin/python-poetry:3.7
1414

15+
env:
16+
TEST_REDIS_SERVER: True
17+
REDIS_HOST: redis
18+
19+
services:
20+
# User a redis container for testing the redis health-provider
21+
redis:
22+
image: redis:5.0.3
23+
1524
steps:
1625
- uses: actions/checkout@v2
1726
- run: make bootstrap
1827
- run: poetry build -vvv
28+
29+
# Install all dependencies except for psutil and run the tests with coverage - this tests handling missing psutil
1930
- run: poetry install --extras flask --extras fastapi --extras aiohttp --extras db --extras redis
2031
- run: make coverage
32+
33+
# Run pylint+mypy after installing psutil so they don't complain on missing dependencies
34+
- run: poetry install --extras psutil
35+
- run: make check
36+
37+
# Run tests with coverage again - this adds tests that require psutil
38+
- run: make coverage
39+
40+
# Upload coverage files to codecov
2141
- uses: actions/upload-artifact@v2
2242
with:
2343
name: htmlcov.zip
2444
path: htmlcov/
2545
- uses: codecov/codecov-action@v1
26-
27-
# Install the extra psutil module and run linting+tests in the "psutil enabled" env
28-
- run: poetry install --extras psutil
29-
- run: make check
30-
- run: make test

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test:
1919
poetry run pytest --log-cli-level=4 -vv tests
2020

2121
coverage:
22-
poetry run pytest --cov-report xml:./coverage.xml --cov-report html --cov-report term --cov=pyctuator --log-cli-level=4 -vv tests
22+
poetry run pytest --cov-append --cov-report xml:./coverage.xml --cov-report html --cov-report term --cov=pyctuator --log-cli-level=4 -vv tests
2323

2424
pylint:
2525
poetry run pylint --exit-zero pyctuator tests

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Monitor Python web apps using
88
[Spring Boot Admin](https://github.com/codecentric/spring-boot-admin).
99

10-
Pyctuator supports **Flask**, **FastAPI** and **aiohttp**. **Django** support is planned as well.
10+
Pyctuator supports **[Flask](https://palletsprojects.com/p/flask/)**, **[FastAPI](https://fastapi.tiangolo.com/)** and **[aiohttp](docs.aiohttp.org)**. **Django** support is planned as well.
1111

1212
The following video shows a FastAPI web app being monitored and controled using Spring Boot Admin.
1313

poetry.lock

Lines changed: 48 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyctuator/impl/aiohttp_pyctuator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from datetime import datetime
55
from functools import partial
66
from http import HTTPStatus
7-
from typing import Any, Callable, List, Mapping, Optional
7+
from typing import Any, Callable, List, Mapping
88

99
from aiohttp import web
1010
from multidict import CIMultiDictProxy

pyctuator/impl/spring_boot_admin_registration.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ def __init__(
3636

3737
self.should_continue_registration_schedule: bool = False
3838

39-
def _schedule_next_registration(
40-
self,
41-
registration_interval_sec: int
42-
) -> None:
39+
def _schedule_next_registration(self, registration_interval_sec: int) -> None:
4340
timer = threading.Timer(
4441
registration_interval_sec,
4542
self._register_with_admin_server,

pyctuator/pyctuator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(
122122
return
123123

124124
# Fail in case no framework was found for the target app
125-
raise EnvironmentError("No framework was found that is matching the target app"
125+
raise EnvironmentError("No framework was found that is matching the target app "
126126
"(is it properly installed and imported?)")
127127

128128
def stop(self) -> None:

tests/aiohttp_test_server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ def start(self) -> None:
7979
time.sleep(0.01)
8080

8181
def stop(self) -> None:
82+
logging.info("Stopping aiohttp server")
8283
self.pyctuator.stop()
8384
self.should_stop_server = True
8485
self.thread.join()
86+
logging.info("aiohttp server stopped")
87+
88+
def atexit(self) -> None:
89+
if self.pyctuator.boot_admin_registration_handler:
90+
self.pyctuator.boot_admin_registration_handler.deregister_from_admin_server()

0 commit comments

Comments
 (0)