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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test that makes sure we close sockets on reloader shutdown #1717

Merged
merged 1 commit into from Oct 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/supervisors/test_reload.py
@@ -1,5 +1,6 @@
import logging
import signal
import socket
from pathlib import Path
from time import sleep
from typing import Optional, Type
Expand Down Expand Up @@ -397,3 +398,13 @@ def test_base_reloader_should_exit(tmp_path):
assert reloader.should_exit.is_set()
with pytest.raises(StopIteration):
reloader.pause()


def test_base_reloader_closes_sockets_on_shutdown():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
config = Config(app="tests.test_config:asgi_app", reload=True)
reloader = BaseReload(config, target=run, sockets=[sock])
reloader.startup()
assert sock.fileno() != -1
reloader.shutdown()
assert sock.fileno() == -1