[Bug] Healthcheck Endpoint Fails
shinybrar opened this issue · comments
Shiny. commented
Pull Request
This bug has been fixed PR #182
Describe the bug
Healthcheck endpoint fails with the following error,
Exception occurred while handling uri: 'http://localhost:8000/health'
Traceback (most recent call last):
File ".venv/lib/python3.9/site-packages/sanic/app.py", line 968, in handle_request
response = await response
File ".venv/lib/python3.9/site-packages/sanic_ext/extensions/health/endpoint.py", line 11, in info
return json(Inspector.make_safe(dict(request.app.m.workers)))
AttributeError: type object 'Inspector' has no attribute 'make_safe'
To Reproduce
Your code snippet or steps to reproduce the bug.
# Contents of test.py
from functools import partial
from sanic import Sanic
from sanic.worker.loader import AppLoader
def create(name: str) -> Sanic:
"""Create the buckets server.
Args:
name (str): The name of the server.
Returns:
Sanic: The sanic server.
"""
app = Sanic(name=name)
app.ctx.debug = app.config.get("DEBUG", True)
app.config.HEALTH = True
app.config.HEALTH_ENDPOINT = True
app.config.HEALTH_URL_PREFIX = "/health"
app.config.FALLBACK_ERROR_FORMAT = "json"
return app
if __name__ == "__main__":
name: str = "test-server"
loader = AppLoader(factory=partial(create, name))
app: Sanic = loader.load()
app.prepare(
host=str(app.config.get("HOSTNAME", "0.0.0.0")),
port=int(app.config.get("PORT", 8000)),
access_log=bool(app.config.get("ACCESS_LOG", True)),
auto_reload=bool(app.config.get("AUTO_RELOAD", True)),
dev=True,
)
Sanic.serve(primary=app, app_loader=loader)
poetry run python test.py
Expected behavior
A clear and concise description of what you expected to happen.
Environment (please complete the following information):
- OS: MacOS 13.0.1
- Browser N/A
- Version N/A
Additional context
The poetry dependencies for the project are given below,
[tool.poetry.dependencies]
python = "^3.8"
sanic = "^22.12.0"
sanic-ext = "^22.12.0"