This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pydanny
Recipients docs@python, gvanrossum, pydanny, vstinner, yselivanov
Date 2014-07-31.02:40:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1406774418.2.0.505776361437.issue22112@psf.upfronthosting.co.za>
In-reply-to
Content
Problem
========

The documentation on asyncio provides an example of a parallel execution of tasks. The code is at: https://docs.python.org/3/library/asyncio-task.html#example-parallel-execution-of-tasks

``` python
import asyncio
 
@asyncio.coroutine
def factorial(name, number):
    f = 1
    for i in range(2, number+1):
        print("Task %s: Compute factorial(%s)..." % (name, i))
        yield from asyncio.sleep(1)
        f *= i
    print("Task %s: factorial(%s) = %s" % (name, number, f))
 
loop = asyncio.get_event_loop()
tasks = [
    loop.create_task(factorial("A", 2)),
    loop.create_task(factorial("B", 3)),
    loop.create_task(factorial("C", 4))]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()
```

Unfortunately, when I try to run this sample code on Python 3.4.1, I run into an error. Specifically, the `loop.create_task()` method does not exist:

``` python
Traceback (most recent call last):
  File "what_me_asynicio.py", line 14, in <module>
    loop.create_task(factorial("A", 2)),
AttributeError: '_UnixSelectorEventLoop' object has no attribute 'create_task'
```

When I perform a dir() on the `loop` object, no `create_task` item is in the result.

System Information
====================

Python Version: 3.4.1
Operating System: OSX 10.9.3
(Also confirmed on Python 3.4.0 in Ubuntu 14.04)
History
Date User Action Args
2014-07-31 02:40:18pydannysetrecipients: + pydanny, gvanrossum, vstinner, docs@python, yselivanov
2014-07-31 02:40:18pydannysetmessageid: <1406774418.2.0.505776361437.issue22112@psf.upfronthosting.co.za>
2014-07-31 02:40:18pydannylinkissue22112 messages
2014-07-31 02:40:17pydannycreate