summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/selector_events.py
diff options
context:
space:
mode:
authorPierre Ossman (ThinLinc team) <ossman@cendio.se>2024-03-11 19:43:30 (GMT)
committerGitHub <noreply@github.com>2024-03-11 19:43:30 (GMT)
commit1d0d49a7e86257ff95b4de0685e6997d7533993c (patch)
tree57b29921aa8502024674411fb495cc9dfaacaadd /Lib/asyncio/selector_events.py
parent872c0714fcdc168ce4a69bdd0346f2d5dd488ec2 (diff)
downloadcpython-1d0d49a7e86257ff95b4de0685e6997d7533993c.zip
cpython-1d0d49a7e86257ff95b4de0685e6997d7533993c.tar.gz
cpython-1d0d49a7e86257ff95b4de0685e6997d7533993c.tar.bz2
gh-113538: Add asycio.Server.{close,abort}_clients (#114432)
These give applications the option of more forcefully terminating client connections for asyncio servers. Useful when terminating a service and there is limited time to wait for clients to finish up their work.
Diffstat (limited to 'Lib/asyncio/selector_events.py')
-rw-r--r--Lib/asyncio/selector_events.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index 8e888d2..f94bf10 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -791,7 +791,7 @@ class _SelectorTransport(transports._FlowControlMixin,
self._paused = False # Set when pause_reading() called
if self._server is not None:
- self._server._attach()
+ self._server._attach(self)
loop._transports[self._sock_fd] = self
def __repr__(self):
@@ -868,6 +868,8 @@ class _SelectorTransport(transports._FlowControlMixin,
if self._sock is not None:
_warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
self._sock.close()
+ if self._server is not None:
+ self._server._detach(self)
def _fatal_error(self, exc, message='Fatal error on transport'):
# Should be called from exception handler only.
@@ -906,7 +908,7 @@ class _SelectorTransport(transports._FlowControlMixin,
self._loop = None
server = self._server
if server is not None:
- server._detach()
+ server._detach(self)
self._server = None
def get_write_buffer_size(self):