Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cannot cleanly shut down an asyncio based server #113538

Closed
Labels
@CendioOssman

Description

@CendioOssman

Bug report

Bug description:

When writing an asyncio based service, you basically have this sequence:

  1. Create an event loop
  2. Register a SIGTERM handler
  3. Start your server
  4. loop.run_forever()
  5. SIGTERM causes aloop.stop()
  6. Close the server
  7. Close event loop

If there are any connections active at this point, then they don't get discarded until interpreter shutdown, with the result that you get a bunch of ResourceWarnings (and cleanup code might not run).

It would be very useful if there was aServer.close_clients() or something like that. Even aServer.all_transports() would be useful, as then you could do something similar as when doing aTask.cancel() on what you get fromloop.all_tasks().

We could poke atServer._transports, but that is something internal that might change in the future.

There isServer.wait_closed(), but that hangs until all clients have gracefully disconnected. It doesn't help us when we want to shut down the servicenow.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp