Skip to content

Commit

Permalink
Update asyncio.async() to use asyncio.ensure_future() fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jul 11, 2016
1 parent 92fb7c3 commit 450045f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions janus/__init__.py
Expand Up @@ -8,11 +8,17 @@
from queue import Empty as SyncQueueEmpty
from queue import Full as SyncQueueFull

__version__ = '0.2.1'
__version__ = '0.2.2'

log = logging.getLogger(__package__)


try:
ensure_future = asyncio.ensure_future
except NameError:
ensure_future = asyncio.async


class Queue:
def __init__(self, maxsize=0, *, loop=None):
if loop is None:
Expand Down Expand Up @@ -128,7 +134,7 @@ def f():
self._async_not_empty.notify()

def task_maker():
task = asyncio.async(f(), loop=self._loop)
task = ensure_future(f(), loop=self._loop)
task.add_done_callback(self._pending.discard)
self._pending.add(task)

Expand All @@ -144,7 +150,7 @@ def f():
self._async_not_full.notify()

def task_maker():
task = asyncio.async(f(), loop=self._loop)
task = ensure_future(f(), loop=self._loop)
task.add_done_callback(self._pending.discard)
self._pending.add(task)

Expand Down

0 comments on commit 450045f

Please sign in to comment.