Skip to content

Commit

Permalink
Add test case for post_fork
Browse files Browse the repository at this point in the history
  • Loading branch information
vickenty committed Mar 5, 2024
1 parent 1b88100 commit b1503b6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/unit/dogstatsd/test_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

0 comments on commit b1503b6

Please sign in to comment.