hypercorn
hypercorn copied to clipboard
How to use reloader with poetry scripts?
Given this set up in somepackage/main.py
def dev():
""" Broken, hypercorn misinterprets what to re-run """
import hypercorn.asyncio
import hypercorn.config
config = hypercorn.config.Config()
config.use_reloader = True
asyncio.run(hypercorn.asyncio.serve(app, config))
And this config in pyproject.toml
:
[tool.poetry.scripts]
dev = "somepackage.main:dev"
Starting in "dev mode" works, but reload does not:
> poetry run dev
# first start
[2022-02-07 13:06:25 +0900] [22745] [INFO] Running on http://127.0.0.1:8000 (CTRL + C to quit)
# now, I'm saving `main.py` again:
/home/user/.cache/pypoetry/virtualenvs/xxx-py3.9/bin/python: can't open file '/home/user/path-to/somepackage/dev': [Errno 2] No such file or directory
I wonder if reloader could somehow introspect the initial run better in order to re-run the app correctly.