New submission from Daniel Greenfeld: 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) ---------- assignee: docs@python components: Documentation, Macintosh, asyncio messages: 224374 nosy: docs@python, gvanrossum, haypo, pydanny, yselivanov priority: normal severity: normal status: open title: '_UnixSelectorEventLoop' object has no attribute 'create_task' versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22112> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com