Commit Graph

138 Commits

Author SHA1 Message Date
Elvis Pranskevichus f9aeca2085 bpo-23859: Document that asyncio.wait() does not cancel its futures (#7217)
Unlike `asyncio.wait_for()`, `asyncio.wait()` does not cancel the passed
futures when a timeout accurs.
2018-05-29 18:21:44 -04:00
Elvis Pranskevichus e2b340ab41 bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216)
Currently, asyncio.wait_for(fut), upon reaching the timeout deadline,
cancels the future and returns immediately.  This is problematic for
when *fut* is a Task, because it will be left running for an arbitrary
amount of time.  This behavior is iself surprising and may lead to
related bugs such as the one described in bpo-33638:

    condition = asyncio.Condition()
    async with condition:
        await asyncio.wait_for(condition.wait(), timeout=0.5)

Currently, instead of raising a TimeoutError, the above code will fail
with `RuntimeError: cannot wait on un-acquired lock`, because
`__aexit__` is reached _before_ `condition.wait()` finishes its
cancellation and re-acquires the condition lock.

To resolve this, make `wait_for` await for the task cancellation.
The tradeoff here is that the `timeout` promise may be broken if the
task decides to handle its cancellation in a slow way.  This represents
a behavior change and should probably not be back-patched to 3.6 and
earlier.
2018-05-29 17:31:01 -04:00
Yury Selivanov 863b674909
bpo-32684: Fix gather to propagate cancel of itself with return_exceptions (GH-7209) 2018-05-29 17:20:02 -04:00
Yury Selivanov 416c1ebd98
bpo-32610: Fix asyncio.all_tasks() to return only pending tasks. (GH-7174) 2018-05-28 17:54:02 -04:00
Yury Selivanov 28b9178023
bpo-32436: Document PEP 567 changes to asyncio. (GH-7073) 2018-05-23 13:35:04 -04:00
Elvis Pranskevichus 63536bd286 bpo-32996: The bulk of What's New in Python 3.7 (GH-6978) 2018-05-19 23:15:06 -04:00
Yury Selivanov d8d715f514
asyncio/docs: Mark asyncio.run() as provisional in 3.7. (#6946) 2018-05-17 13:44:00 -04:00
Andrew Svetlov b21505e710
Fix docs markup for asyncio current_task() and all_tasks() (#6089) 2018-03-12 20:50:50 +02:00
Joongi Kim 13cfd57dcf Fix missing coroutine declaration in the asyncio documentation. (#5964) 2018-03-03 18:43:54 +02:00
Yury Selivanov ca9b36cd1a
bpo-32415: Add asyncio.Task.get_loop() and Future.get_loop() (#4992) 2017-12-23 15:04:15 -05:00
Andrew Svetlov 44d1a5912e
bpo-32250: Implement asyncio.current_task() and asyncio.all_tasks() (#4799) 2017-12-16 21:58:38 +02:00
Andrew Svetlov f74ef458ab
bpo-32311: Implement asyncio.create_task() shortcut (#4848)
* Implement functionality
* Add documentation
2017-12-15 07:04:38 +02:00
Yury Selivanov 02a0a19206
bpo-32314: Implement asyncio.run() (#4852) 2017-12-14 09:42:21 -05:00
Andrew Svetlov 8874342cf3
bpo-32258: Replace 'yield from' to 'await' in asyncio docs (#4779)
* Replace 'yield from' to 'await' in asyncio docs

* Fix docstrings
2017-12-11 17:35:49 +02:00
Yury Selivanov 9edad3c701
bpo-32272: Remove asyncio.async() function. (#4784) 2017-12-11 10:03:48 -05:00
Antoine Pitrou 22b1128559
bpo-31960: Fix asyncio.Future documentation for thread (un)safety. (#4319) 2017-11-07 17:03:28 +01:00
luzpaz a5293b4ff2 Fix miscellaneous typos (#4275) 2017-11-05 15:37:50 +02:00
lf 627d2c8e8d Add the link to asyncio source code in the docs (GH-2373) 2017-07-25 16:03:51 -07:00
adisbladis 824f687912 bpo-24755: Document asyncio.wrap_future (GH-603) 2017-06-08 23:28:59 -07:00
Berker Peksag f59286794b Issue #29441: Update examples to use async and await keywords in asyncio-task.rst 2017-02-07 11:27:09 +03:00
Berker Peksag d5adb63673 Issue #29407: Remove redundant ensure_future() calls in factorial example 2017-02-01 22:37:16 +03:00
Serhiy Storchaka 4adf01caae Issue #19795: Improved more markups of True/False. 2016-10-19 18:30:05 +03:00
Berker Peksag 002b0a7ecd Issue #28348: Fix typo in asyncio.Task() documentation
Patch by Mariatta Wijaya.
2016-10-04 20:45:47 +03:00
Guido van Rossum f68afd8544 Issue #27700: Document AbstractEventLoop, not BaseEventLoop. 2016-08-08 09:41:21 -07:00
Andrew Svetlov 4365b8302d Use asyncio.gather instead of asyncio.wait in example.
gather will raise exception in case of problem but wait just returns done and pending lists of futures.
For getting error every future result should be retrieved, which is boring and error prone.
2016-08-08 03:10:39 +03:00
Yury Selivanov c1cf296de6 asyncio: Remove asyncio.timeout() context manager.
It will probably be added back in Python 3.6, once its compatibility
issues are resolved; see [1] for more details.

[1] https://mail.python.org/pipermail/async-sig/2016-June/000045.html
2016-06-08 13:57:03 -04:00
Zachary Ware f9aff925e0 Fix typo 2016-06-01 00:01:10 -05:00
Yury Selivanov 950204df9c docs: Update asyncio docs & whatsnew 2016-05-16 16:23:00 -04:00
Andrew Svetlov 6f57424ae0 Document None as timeout for asyncio.timeout() 2016-03-29 09:39:02 +03:00
Martin Panter c04fb56e36 Issue #26304: Change "allows to <verb>" to "allows <verb>ing" or similar
The original form is incorrect grammar and feels awkward, even though the
meaning is clear.
2016-02-10 05:44:01 +00:00
Andrew Svetlov ea471348f4 Fix versionadded to use 3.5.1 only for 3.5 branch 2016-01-11 15:41:43 +02:00
Andrew Svetlov 3af81f2505 merge 3.4 2016-01-11 14:45:25 +02:00
Andrew Svetlov f1240169b3 Document asyncio.timeout() 2016-01-11 14:40:35 +02:00
Yury Selivanov e319ab01ce docs/asyncio: Update ensure_future & run_coroutine_threadsafe docs 2015-12-15 00:45:24 -05:00
Yury Selivanov 6efc7e726f Merge 3.4 2015-11-18 12:44:49 -05:00
Yury Selivanov 01a65af4a1 asyncio.docs: Fix versionadded 2015-11-18 12:44:31 -05:00
Guido van Rossum 5db034acfa Docs and one small improvement for issue #25304, by Vincent Michel. (Merge 3.4->3.5.) 2015-10-05 16:23:13 -07:00
Guido van Rossum 601953b679 Docs and one small improvement for issue #25304, by Vincent Michel. 2015-10-05 16:20:00 -07:00
Yury Selivanov 04356e1f6f Issue #24487: Rename async() -> ensure_future() in asyncio docs.
Patch by Martin Panter.
2015-06-30 22:13:22 -04:00
Yury Selivanov 66f8828bfc Issue #24439: Improve PEP 492 related docs.
Patch by Martin Panter.
2015-06-24 11:04:15 -04:00
Yury Selivanov d7e19bb566 docs/asyncio: Document new ensure_future() and deprecated async() 2015-05-11 16:33:41 -04:00
Victor Stinner 72dcb0a765 Issue #23219: Update asyncio.wait_for() documentation
the wait is cancelled, the future *fut* is now also cancelled.
2015-04-03 17:08:19 +02:00
Victor Stinner 83704963c0 asyncio: add a note about (non) thread safety in each class 2015-02-25 14:24:15 +01:00
Victor Stinner bdd574d09a asyncio doc: annotate coroutine on coroutine functions and methods 2015-02-12 22:49:18 +01:00
Victor Stinner d87de83582 Closes #22475: asyncio doc, fix Task.get_stack() doc 2014-12-02 17:57:04 +01:00
Victor Stinner 039f703b7b Close #22473: asyncio doc: rephrase Future with run_forever() example 2014-12-02 17:52:45 +01:00
Victor Stinner 8464c24c82 asyncio doc: explain how to pass keywords to callbacks (functools.partial) 2014-11-28 13:15:41 +01:00
Victor Stinner 7f314ed71b asyncio doc: write simpler examples to introduce asyncio 2014-10-15 18:49:16 +02:00
Victor Stinner 980dd84f92 asyncio doc: more explicit doc for async()
The function schedules the execution of coroutines, it's not just a wrapper for
something.
2014-10-12 21:36:17 +02:00
Victor Stinner 6888b96cee asyncio doc: cleanup Hello World examples 2014-10-11 16:15:58 +02:00
Berker Peksag 9c1dba2758 Revert #22251 2014-09-28 00:00:58 +03:00
Berker Peksag 3749404ba5 Issue #22251: Fix ReST markup to avoid errors building docs. 2014-09-27 23:21:35 +03:00
R David Murray 22dd8334cd Improve English phrasing in asyncio task docs. 2014-09-24 11:09:09 -04:00
Victor Stinner 337e03ff78 Issue #22112, asyncio doc: replace loop.create_task(coro) with
asyncio.async(coro), mention that asyncio.async() can be used to scheduler a
coroutine, and make it clear that create_task() is only available in Python
3.4.2 and later.
2014-08-11 01:11:13 +02:00
Terry Jan Reedy c935a9530c Englich grammar nit. 2014-07-24 02:33:14 -04:00
Victor Stinner 530ef2f069 Update asyncio documentation
- Document the new create_task() method
- "Hide" the Task class: point to the create_task() method for interoperability
- Rewrite the documentation of the Task class
- Document the "Pending task destroyed"
- Update output in debug mode of examples in the dev section
- Replace Task() with create_task() in examples
2014-07-08 12:39:10 +02:00
Victor Stinner 63b21a8ffa Closes #21921: Fix ResourceWarning in the asyncio examples: close the event
loop at exit. Patch written by Vajrasky Kok (I modified also the "hello world"
example using a coroutine).
2014-07-05 15:38:59 +02:00
Victor Stinner db74d982d4 Issue #21596: asyncio.wait(): mention that the sequence of futures must not
be empty.
2014-06-10 11:16:05 +02:00
Victor Stinner 8d21357fb5 Issue #21601: Document asyncio.Task.cancel(). Initial patch written by Vajrasky
Kok.
2014-06-02 23:06:46 +02:00
Victor Stinner 28d0ae48e9 Issue #21376: document asyncio.TimeoutError 2014-05-29 00:04:57 +02:00
Yury Selivanov 37f15bcfed asyncio.docs: Improve wordings; add a note to the Coroutines section. Issue #20706 2014-02-20 16:20:44 -05:00
Victor Stinner 04e05da1b3 Close #20652: asyncio doc: close the event loop in run_forever() example. Fix
also typo. Patch written by Vajrasky Kok.
2014-02-17 10:54:30 +01:00
Brian Curtin c9d1a6b85e merge 2014-02-08 18:36:57 -06:00
Brian Curtin a1afeec9aa Spelling corrections. Submitted to python-dev by python@mrabarnett.plus.com 2014-02-08 18:36:14 -06:00
Victor Stinner 12c68b20b7 asyncio doc: fix gather() doc 2014-02-09 01:35:24 +01:00
Victor Stinner 45b27ed53d asyncio doc: document the granularity of the event loop
Improve also the "Logging" section
2014-02-01 02:36:43 +01:00
Victor Stinner 1ad5afc050 asyncio: document iscoroutine(), iscoroutinefunction() and wait_for()
Mention that wait_for() now accepts None for the timeout.
2014-01-30 00:18:50 +01:00
Victor Stinner f40c66334d asyncio doc: close the loop at exit 2014-01-28 23:32:40 +01:00
Eli Bendersky 029981bbfc Clarify what the loop arguments means for functions listed in 18.5.2.5 2014-01-20 07:02:22 -08:00
Eli Bendersky 2d26af82c1 Explain the 'result' argument in asyncio.sleep 2014-01-20 06:59:23 -08:00
Victor Stinner 59759ff234 asyncio doc: replace "coroutine" with "coroutine object" or "coroutine function" 2014-01-16 19:30:21 +01:00
Victor Stinner db39a0da0c asyncio: add a new "Develop with asyncio" section to the documentation 2014-01-16 18:58:01 +01:00
R David Murray 6a14381530 Fix Sphinx markup for asyncio modules so :mod:`asyncio` links work. 2013-12-20 14:37:39 -05:00
Victor Stinner 86e139ad65 asyncio doc: explain where does the task come from. 2013-12-13 12:51:24 +01:00
Victor Stinner 1c4b892d71 Add a sequence diagram for the chained coroutines example 2013-12-12 12:35:17 +01:00
Victor Stinner a6fa15367f asyncio doc: simplify task example 2013-12-10 12:20:14 +01:00
Victor Stinner 0839ed4730 asyncio doc: don't document Task.cancel(), already documented in Future.cancel() 2013-12-10 12:18:15 +01:00
Victor Stinner 742520be43 asyncio: document Task.current_task() 2013-12-10 12:14:50 +01:00
Victor Stinner fc25d629ab asyncio: don't document private functions 2013-12-10 02:52:49 +01:00
Victor Stinner 34f2946a11 asyncio: fix 2nd task example 2013-12-10 02:51:05 +01:00
Victor Stinner b69d62dcac assyncio doc: rewrite, improve and move coroutine, Future and Task examples 2013-12-10 02:09:46 +01:00
Victor Stinner d8f11e9265 asyncio: another Future example using add_done_callback() 2013-12-09 13:04:12 +01:00
Victor Stinner 45c2fd9f8a asyncio doc: add an example with Future 2013-12-09 12:40:17 +01:00
Victor Stinner 99c2ab4b83 asyncio doc: oh, asyncio module has its own Future class
Improve also wait() documentation: mention that the first parameter is a
sequence
2013-12-03 19:17:25 +01:00
Victor Stinner c6fba92ebc asyncio doc: add one more example of coroutines 2013-12-03 17:37:31 +01:00
Victor Stinner 933a8c82ce asyncio doc: reorder methods; typo 2013-12-03 01:59:38 +01:00
Victor Stinner 3e09e32c8a asyncio doc: move coroutine example to the Task page 2013-12-03 01:22:06 +01:00
Victor Stinner ea3183f5b8 Split asyncio documentation into subfiles 2013-12-03 01:08:00 +01:00