Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
Issue #29441: Update examples to use async and await keywords in asyn…
Browse files Browse the repository at this point in the history
…cio-task.rst

--HG--
branch : 3.5
  • Loading branch information
berkerpeksag committed Feb 7, 2017
1 parent d0a5fc4 commit 7c9f09e
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,6 @@ using the :meth:`sleep` function::
loop.run_until_complete(display_date(loop))
loop.close()

The same coroutine implemented using a generator::

@asyncio.coroutine
def display_date(loop):
end_time = loop.time() + 5.0
while True:
print(datetime.datetime.now())
if (loop.time() + 1.0) >= end_time:
break
yield from asyncio.sleep(1)

.. seealso::

The :ref:`display the current date with call_later()
Expand Down Expand Up @@ -309,9 +298,8 @@ Example combining a :class:`Future` and a :ref:`coroutine function

import asyncio

@asyncio.coroutine
def slow_operation(future):
yield from asyncio.sleep(1)
async def slow_operation(future):
await asyncio.sleep(1)
future.set_result('Future is done!')

loop = asyncio.get_event_loop()
Expand Down Expand Up @@ -341,9 +329,8 @@ flow::

import asyncio

@asyncio.coroutine
def slow_operation(future):
yield from asyncio.sleep(1)
async def slow_operation(future):
await asyncio.sleep(1)
future.set_result('Future is done!')

def got_result(future):
Expand Down

0 comments on commit 7c9f09e

Please sign in to comment.