From a0e34b0bc8b04a022df390146004fa7a3760d511 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 18 Feb 2022 17:21:37 -0300 Subject: [PATCH] make timeout handler immune to asyncio time tricks --- lbry/testcase.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lbry/testcase.py b/lbry/testcase.py index b10ea9b27..6214553e5 100644 --- a/lbry/testcase.py +++ b/lbry/testcase.py @@ -204,7 +204,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):