MCPcopy
hub / github.com/tornadoweb/tornado / test_garbage_collection

Method test_garbage_collection

tornado/test/locks_test.py:178–194  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

176
177 @gen_test
178 def test_garbage_collection(self):
179 # Test that timed-out waiters are occasionally cleaned from the queue.
180 c = locks.Condition()
181 for _ in range(101):
182 c.wait(timedelta(seconds=0.01))
183
184 future = asyncio.ensure_future(c.wait())
185 self.assertEqual(102, len(c._waiters))
186
187 # Let first 101 waiters time out, triggering a collection.
188 yield gen.sleep(0.02)
189 self.assertEqual(1, len(c._waiters))
190
191 # Final waiter is still active.
192 self.assertFalse(future.done())
193 c.notify()
194 self.assertTrue(future.done())
195
196
197class EventTest(AsyncTestCase):

Callers

nothing calls this directly

Calls 3

waitMethod · 0.95
notifyMethod · 0.95
doneMethod · 0.45

Tested by

no test coverage detected