make timeout handler immune to asyncio time tricks
This commit is contained in:
parent
521d783260
commit
c2a3ec3265
1 changed files with 7 additions and 1 deletions
|
@ -202,7 +202,13 @@ class AsyncioTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def add_timeout(self):
|
def add_timeout(self):
|
||||||
if self.TIMEOUT:
|
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):
|
class AdvanceTimeTestCase(AsyncioTestCase):
|
||||||
|
|
Loading…
Add table
Reference in a new issue