summary refs log tree commit diff
path: root/tests/logging
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2020-10-29 12:53:57 -0400
committerGitHub <noreply@github.com>2020-10-29 12:53:57 -0400
commit8b42a4eefda409dfef9a3d10c9f55a778cae46a1 (patch)
tree91e4cc793d4d7bd5a96273f611847786e3c462cb /tests/logging
parentAdd ability for access tokens to belong to one user but grant access to anoth... (diff)
downloadsynapse-8b42a4eefda409dfef9a3d10c9f55a778cae46a1.tar.xz
Gracefully handle a pending logging connection during shutdown. (#8685)
Diffstat (limited to 'tests/logging')
-rw-r--r--tests/logging/test_remote_handler.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/logging/test_remote_handler.py b/tests/logging/test_remote_handler.py
index 58ee1f2f3c..4bc27a1d7d 100644
--- a/tests/logging/test_remote_handler.py
+++ b/tests/logging/test_remote_handler.py
@@ -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()