mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
asyncio: Fix _SelectorTransport.__repr__() if the event loop is closed
This commit is contained in:
parent
0b4e355b8e
commit
79fd962652
2 changed files with 6 additions and 1 deletions
|
@ -535,7 +535,7 @@ class _SelectorTransport(transports._FlowControlMixin,
|
||||||
info.append('closing')
|
info.append('closing')
|
||||||
info.append('fd=%s' % self._sock_fd)
|
info.append('fd=%s' % self._sock_fd)
|
||||||
# test if the transport was closed
|
# test if the transport was closed
|
||||||
if self._loop is not None:
|
if self._loop is not None and not self._loop.is_closed():
|
||||||
polling = _test_selector_event(self._loop._selector,
|
polling = _test_selector_event(self._loop._selector,
|
||||||
self._sock_fd, selectors.EVENT_READ)
|
self._sock_fd, selectors.EVENT_READ)
|
||||||
if polling:
|
if polling:
|
||||||
|
|
|
@ -62,6 +62,11 @@ class BaseSelectorEventLoopTests(test_utils.TestCase):
|
||||||
self.loop.add_reader._is_coroutine = False
|
self.loop.add_reader._is_coroutine = False
|
||||||
transport = self.loop._make_socket_transport(m, asyncio.Protocol())
|
transport = self.loop._make_socket_transport(m, asyncio.Protocol())
|
||||||
self.assertIsInstance(transport, _SelectorSocketTransport)
|
self.assertIsInstance(transport, _SelectorSocketTransport)
|
||||||
|
|
||||||
|
# Calling repr() must not fail when the event loop is closed
|
||||||
|
self.loop.close()
|
||||||
|
repr(transport)
|
||||||
|
|
||||||
close_transport(transport)
|
close_transport(transport)
|
||||||
|
|
||||||
@unittest.skipIf(ssl is None, 'No ssl module')
|
@unittest.skipIf(ssl is None, 'No ssl module')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue