Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions uvicorn/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import time
from email.utils import formatdate
from types import FrameType
from typing import TYPE_CHECKING, List, Optional, Sequence, Set, Tuple, Union
from typing import TYPE_CHECKING, Any, List, Optional, Sequence, Set, Tuple, Union

import click

Expand Down Expand Up @@ -54,6 +54,7 @@ def __init__(self, config: Config) -> None:
self.should_exit = False
self.force_exit = False
self.last_notified = 0.0
self.servers: List[Any] = []

def run(self, sockets: Optional[List[socket.socket]] = None) -> None:
self.config.setup_event_loop()
Expand Down Expand Up @@ -112,7 +113,9 @@ def _share_socket(
sock_data = sock.share(os.getpid()) # type: ignore[attr-defined]
return fromshare(sock_data)

self.servers = []
# Ensure list does not have stale items if the server is run multiple times.
self.servers.clear()

for sock in sockets:
if config.workers > 1 and platform.system() == "Windows":
sock = _share_socket( # type: ignore[assignment]
Expand Down