summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-11-05 19:29:04 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-11-05 19:29:04 (GMT)
commitade0412613f7628e34d947168cd5f447fa6b8f17 (patch)
treead5a538d7b910663c15a4e40cdca8f98a74108c8 /Lib/asyncio
parent5be2dac560018fee60c9435d19362117b9221677 (diff)
downloadcpython-ade0412613f7628e34d947168cd5f447fa6b8f17.zip
cpython-ade0412613f7628e34d947168cd5f447fa6b8f17.tar.gz
cpython-ade0412613f7628e34d947168cd5f447fa6b8f17.tar.bz2
asyncio: Optimize asyncio.sleep(0)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/tasks.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index b887d88..77a93e0 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -488,6 +488,10 @@ def as_completed(fs, *, loop=None, timeout=None):
@coroutine
def sleep(delay, result=None, *, loop=None):
"""Coroutine that completes after a given time (in seconds)."""
+ if delay == 0:
+ yield
+ return result
+
future = futures.Future(loop=loop)
h = future._loop.call_later(delay,
future._set_result_unless_cancelled, result)