File tree 1 file changed +5
-8
lines changed
1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -761,18 +761,13 @@ async def _close(self, close_connections: bool) -> None:
761
761
# Stop accepting new connections.
762
762
self .server .close ()
763
763
764
- # Wait until self.server.close() completes.
765
- await self .server .wait_closed ()
766
-
767
764
# Wait until all accepted connections reach connection_made() and call
768
765
# register(). See https://bugs.python.org/issue34852 for details.
769
766
await asyncio .sleep (0 )
770
767
771
768
if close_connections :
772
- # Close OPEN connections with status code 1001. Since the server was
773
- # closed, handshake() closes OPENING connections with an HTTP 503
774
- # error. Wait until all connections are closed.
775
-
769
+ # Close OPEN connections with close code 1001. After server.close(),
770
+ # handshake() closes OPENING connections with an HTTP 503 error.
776
771
close_tasks = [
777
772
asyncio .create_task (websocket .close (1001 ))
778
773
for websocket in self .websockets
@@ -782,8 +777,10 @@ async def _close(self, close_connections: bool) -> None:
782
777
if close_tasks :
783
778
await asyncio .wait (close_tasks )
784
779
785
- # Wait until all connection handlers are complete.
780
+ # Wait until all TCP connections are closed.
781
+ await self .server .wait_closed ()
786
782
783
+ # Wait until all connection handlers terminate.
787
784
# asyncio.wait doesn't accept an empty first argument.
788
785
if self .websockets :
789
786
await asyncio .wait (
You can’t perform that action at this time.
0 commit comments