make timeout handler immune to asyncio time tricks

This commit is contained in:
Victor Shyba 2022-02-18 17:21:37 -03:00
parent 521d783260
commit c2a3ec3265

View file

@ -202,7 +202,13 @@ class AsyncioTestCase(unittest.TestCase):
def add_timeout(self):
if self.TIMEOUT:
self.loop.call_later(self.TIMEOUT, self.cancel)
self.loop.call_later(self.TIMEOUT, self.check_timeout, time())
def check_timeout(self, started):
if time() - started >= self.TIMEOUT:
self.cancel()
else:
self.loop.call_later(self.TIMEOUT, self.check_timeout, started)
class AdvanceTimeTestCase(AsyncioTestCase):