[Python-Dev] cpython: Issue #20311: asyncio: Add a granularity attribute to BaseEventLoop: maximum (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Sat Jan 25 22:35:34 CET 2014


On Sat, 25 Jan 2014 15:02:56 +0100 (CET) victor.stinner <python-checkins at python.org> wrote:

+ + @tasks.coroutine + def wait(): + loop = self.loop + calls.append(loop.runoncecounter) + yield from tasks.sleep(loop.granularity * 10, loop=loop) + calls.append(loop.runoncecounter) + yield from tasks.sleep(loop.granularity / 10, loop=loop) + calls.append(loop.runoncecounter) + + self.loop.rununtilcomplete(wait()) + calls.append(self.loop.runoncecounter) + self.assertEqual(calls, [1, 3, 5, 6])

Could you add a comment explaining the number of calls to run_once()? For example, why does it jump from 1 to 3 and then 3 to 5, rather than 1 to 2 and then 2 to 3?

Regards

Antoine.



More information about the Python-Dev mailing list