Skip to content

Document the need to catch GracefulExit if handle_signals=True #4414

Closed
@webknjaz

Description

Long story short

I've been using low-level machinery exposed by aiohttp for my framework.
When I learned about handle_signals=True I started testing it and it turned out that my process always exited with return code 1 on SIGTERM and SIGINT.

This was confusing and I thought that it's a bug. But then, after diving into the code deeper, I realized that with this option enabled, aiohttp binds the corresponding handler to process these signals and the only thing they do is raising GracefulExit (which is a subclass of SystemExit with the return code defaulting to 1).

Turns out that it works but only if one uses aiohttp.web.run_app(). This was the last bit of the puzzle for me: using low-level APIs implies that I mostly don't rely on high-level interfaces and thus have to catch the GracefulExit exception in my own runner code.

So my request here is that this should be documented.

I'm marking this as a "good first issue" so that new contributors could have something easy to start with.

Expected behaviour

Docs clarifying this.

Actual behaviour

Docs don't mention this detail.

Steps to reproduce

N/A

Your environment

N/A

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestWe think it's good for https://hacktoberfest.digitalocean.com/documentationImprovements or additions to documentationenhancementgood first issueGood for newcomersserver

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions