Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hypercorn autoreload return exit status 0 when reloading encounters Python SyntaxError #269

Open
dodysw3 opened this issue Dec 13, 2024 · 0 comments

Comments

@dodysw3
Copy link

dodysw3 commented Dec 13, 2024

Problem: exit status 0 is returned when hypercorn with --reload throws an exception like SyntaxError, making the wrapper unable to distinguish if the exit is graceful or not (e.g. systemd auto restart on-failure)

Expectation: exit status non-0 should be returned in this condition.

Reproducing:

app.py:

# pip install hypercorn quart
from quart import Quart

app = Quart(__name__)

@app.route('/')
async def hello():
    return "Hello, World!"

if __name__ == '__main__':
    import hypercorn.asyncio
    from hypercorn.config import Config

    config = Config()
    config.bind = ["127.0.0.1:8000"]

    import asyncio
    asyncio.run(hypercorn.asyncio.serve(app, config))
hypercorn --reload app:app

Then make the syntax error, e.g.:

...
    return "Hello, World!" }
...

The result:

  File "/Users/dody/code/coba/app.py", line 8
    return "Hello, World!"}
                          ^
SyntaxError: unmatched '}'
(venv) $ echo $?
0

This works as expected when hypercorn encounters the syntaxerror before reloading: (continuing from above)

hypercorn --reload app:app
...
  File "/Users/dody/code/coba/app.py", line 8
    return "Hello, World!" }
                           ^
SyntaxError: unmatched '}'
(venv) $ echo $?
1

Thanks for checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant