Skip to content

Commit

Permalink
fix(asyncio): use asyncio.async when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
h2non committed Jan 28, 2017
1 parent 170c128 commit 254a255
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion paco/interval.py
Expand Up @@ -3,6 +3,11 @@
from .decorator import decorate
from .assertions import assert_corofunction

try:
ensure_future = asyncio.ensure_future
except:
ensure_future = getattr(asyncio, 'async')


@decorate
def interval(coro, interval=1, times=None):
Expand Down Expand Up @@ -62,6 +67,6 @@ def schedule(times, *args, **kw):
yield from asyncio.sleep(interval)

def wrapper(*args, **kw):
return asyncio.ensure_future(schedule(times, *args, **kw))
return ensure_future(schedule(times, *args, **kw))

return wrapper

0 comments on commit 254a255

Please sign in to comment.