Gracefully handle a pending logging connection during shutdown. (#8685)

This commit is contained in:
Patrick Cloke 2020-10-29 12:53:57 -04:00 committed by GitHub
parent f21e24ffc2
commit 8b42a4eefd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 10 deletions

View file

@ -151,3 +151,19 @@ class RemoteHandlerTestCase(LoggerCleanupMixin, TestCase):
+ ["warn %s" % (i,) for i in range(15, 20)],
logs,
)
def test_cancel_connection(self):
"""
Gracefully handle the connection being cancelled.
"""
handler = RemoteHandler(
"127.0.0.1", 9000, maximum_buffer=10, _reactor=self.reactor
)
logger = self.get_logger(handler)
# Send a message.
logger.info("Hello there, %s!", "wally")
# Do not accept the connection and shutdown. This causes the pending
# connection to be cancelled (and should not raise any exceptions).
handler.close()