From b1503b60d1e582010eb0bd330dfb968ae47a0d54 Mon Sep 17 00:00:00 2001 From: Vikentiy Fesunov Date: Tue, 5 Mar 2024 17:52:16 +0000 Subject: [PATCH] Add test case for post_fork --- tests/unit/dogstatsd/test_statsd.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unit/dogstatsd/test_statsd.py b/tests/unit/dogstatsd/test_statsd.py index d83a0ea5a..15a9c8bdf 100644 --- a/tests/unit/dogstatsd/test_statsd.py +++ b/tests/unit/dogstatsd/test_statsd.py @@ -1963,3 +1963,16 @@ def test_max_payload_size(self): self.assertEqual(statsd._max_payload_size, UDP_OPTIMAL_PAYLOAD_LENGTH) statsd.socket_path = "/foo" self.assertEqual(statsd._max_payload_size, UDS_OPTIMAL_PAYLOAD_LENGTH) + + def test_post_fork_locks(self): + def inner(): + statsd = DogStatsd(socket_path=None, port=8125) + # Statsd should survive this sequence of events + statsd.pre_fork() + statsd.get_socket() + statsd.post_fork() + t = Thread(target=inner) + t.daemon = True + t.start() + t.join(timeout=5) + self.assertFalse(t.is_alive())