diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2014-01-25 15:01:33 +0100 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2014-01-25 15:01:33 +0100 |
| commit | f67255ab94742b017697bdedfd4c8eb25dac6f82 (patch) | |
| tree | 391dc1e1c5a305ae4cc9bccec135a9bb6206e37f /Lib/test/test_asyncio/test_events.py | |
| parent | 635fca9704b102a97233a3af18231a7b649d0169 (diff) | |
| download | cpython-git-f67255ab94742b017697bdedfd4c8eb25dac6f82.tar.gz | |
Issue #20311: asyncio: Add a granularity attribute to BaseEventLoop: maximum
between the resolution of the BaseEventLoop.time() method and the resolution of
the selector. The granuarility is used in the scheduler to round time and
deadline.
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_events.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 21036b5f7b..7a4d69834d 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -1116,6 +1116,29 @@ class EventLoopTestsMixin: r.close() w.close() + def test_timeout_rounding(self): + def _run_once(): + self.loop._run_once_counter += 1 + orig_run_once() + + orig_run_once = self.loop._run_once + self.loop._run_once_counter = 0 + self.loop._run_once = _run_once + calls = [] + + @tasks.coroutine + def wait(): + loop = self.loop + calls.append(loop._run_once_counter) + yield from tasks.sleep(loop.granularity * 10, loop=loop) + calls.append(loop._run_once_counter) + yield from tasks.sleep(loop.granularity / 10, loop=loop) + calls.append(loop._run_once_counter) + + self.loop.run_until_complete(wait()) + calls.append(self.loop._run_once_counter) + self.assertEqual(calls, [1, 3, 5, 6]) + class SubprocessTestsMixin: |
