summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
Commit message (Collapse)AuthorAgeFilesLines
* bpo-39529: Deprecate creating new event loop in asyncio.get_event_loop() ↵Serhiy Storchaka2021-04-254-27/+44
| | | | | | (GH-23554) asyncio.get_event_loop() emits now a deprecation warning when it creates a new event loop. In future releases it will became an alias of asyncio.get_running_loop().
* bpo-41891: ensure asyncio.wait_for waits for task completion (#22461)Richard Kojedzinszky2020-12-181-1/+4
|
* bpo-38323: Add guard clauses in MultiLoopChildWatcher. (#22756)Chris Jerdonek2020-12-161-14/+18
| | | This is a trivial refactor in preparation for a fix for bpo-38323.
* bpo-40364: asyncio uses os.waitstatus_to_exitcode() (GH-23798)Victor Stinner2020-12-161-19/+15
| | | | | test_unix_events.py no longer checks if waitstatus_to_exitcode() mock has been called or not to make the test more functional, rather than checking the exact implementation.
* bpo-42582: Remove asyncio._all_tasks_compat(). (GH-23664)Serhiy Storchaka2020-12-062-28/+0
| | | It was used to implement now removed asyncio.Task.all_tasks().
* bpo-34215: Clarify IncompleteReadError message when "expected" is None ↵Zackery Spytz2020-11-281-1/+2
| | | | | (GH-21925) Co-Authored-By: Tyler Bell <mrbell321@gmail.com>
* bpo-41241: Unnecessary Type casting in 'if condition' (GH-21396)Wansoo Kim2020-11-281-1/+1
| | | | | | | | This is my first issue! So, if there's anything wrong, please tell me! Also, thank you always for all the contributors! Automerge-Triggered-By: GH:asvetlov
* bpo-42392: Remove loop parameter from asyncio.tasks and asyncio.subprocess ↵Yurii Karabas2020-11-285-74/+25
| | | | (GH-23521)
* bpo-41332: Added missing connect_accepted_socket() to AbstractEventLoop ↵Alex Grönholm2020-11-262-8/+14
| | | | | | (GH-21533) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com> Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* bpo-42392: Remove loop parameter from asyncio.streams (GH-23517)Yurii Karabas2020-11-261-28/+9
|
* bpo-42392: Improve removal of *loop* parameter in asyncio primitives (GH-23499)Yurii Karabas2020-11-253-14/+29
| | | | | | | | | | * Update code after merge review from 1st1 * Use a sentinel approach for loop parameter Remove unnecessary _get_running_loop patching * Use more clear function name (_verify_parameter_is_marker -> _verify_no_loop) * Add init method to _LoopBoundMixin to check that loop param wasn't used
* bpo-42392: Remove loop parameter form asyncio locks and Queue (#23420)Yurii Karabas2020-11-244-67/+45
| | | Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-42140: Improve asyncio.wait function (GH-22938)Diogo Dutra2020-11-101-2/+4
| | | | | | | | | | # Improve asyncio.wait function The original code creates the futures set two times. We can create this set before, avoiding the second creation. This new behaviour [breaks the aiokafka library](https://github.com/aio-libs/aiokafka/pull/672), because it gives an iterator to that function, so the second iteration become empty. Automerge-Triggered-By: GH:1st1
* bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() ↵Andrew Svetlov2020-11-101-3/+22
| | | | | | | | (GH-23020) The overflow occurs under some circumstances when a task or future recursively returns itself. Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* bpo-42230: Improve asyncio documentation regarding accepting sets vs ↵Jakub Stasiak2020-11-021-2/+2
| | | | | | | | | | | | | | iterables (GH-23073) People call wait() and as_completed() with various non-set iterables, a list should be the most common but there are others as well[1]. Considering typeshed also documents wait()[2] and as_completed()[3] as accepting arbitrary iterables I think it's a good idea to document the status quo better. [1] https://github.com/aio-libs/aiokafka/pull/672 [2] https://github.com/python/typeshed/blob/620989bac572f30349b95590ebe81a73ce0fe862/stdlib/3/asyncio/tasks.pyi#L161 [3] https://github.com/python/typeshed/blob/620989bac572f30349b95590ebe81a73ce0fe862/stdlib/3/asyncio/tasks.pyi#L40
* bpo-39651: Fix asyncio proactor _write_to_self() (GH-22197)Victor Stinner2020-09-122-9/+20
| | | | | Fix a race condition in the call_soon_threadsafe() method of asyncio.ProactorEventLoop: do nothing if the self-pipe socket has been closed.
* bpo-41696: Fix handling of debug mode in asyncio.run (#22069)Shantanu2020-09-031-2/+3
| | | | | | | | | | | * bpo-41696: Fix handling of debug mode in asyncio.run This allows PYTHONASYNCIODEBUG or -X dev to enable asyncio debug mode when using asyncio.run * 📜🤖 Added by blurb_it. Co-authored-by: hauntsaninja <> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* bpo-39010: Fix errors logged on proactor loop restart (#22017)Ben Darnell2020-08-312-2/+14
| | | | | | Stopping and restarting a proactor event loop on windows can lead to spurious errors logged (ConnectionResetError while reading from the self pipe). This fixes the issue by ensuring that we don't attempt to start multiple copies of the self-pipe reading loop.
* bpo-37658: Fix asyncio.wait_for() to respect waited task status (#21894)Elvis Pranskevichus2020-08-261-3/+6
| | | | | | Currently, if `asyncio.wait_for()` itself is cancelled it will always raise `CancelledError` regardless if the underlying task is still running. This is similar to a race with the timeout, which is handled already.
* bpo-32751: Wait for task cancel in asyncio.wait_for() when timeout <= 0 (#21895)Elvis Pranskevichus2020-08-261-2/+7
| | | | | | When I was fixing bpo-32751 back in GH-7216 I missed the case when *timeout* is zero or negative. This takes care of that. Props to @aaliddell for noticing the inconsistency.
* bpo-41572: Fix grammar in BaseTransport.close docstring (GH-21914)Cleber Rosa2020-08-201-2/+2
| | | | | | | Fix grammar in BaseTransport.close docstring. https://bugs.python.org/issue41572 Signed-off-by: Cleber Rosa <crosa@redhat.com>
* bpo-40782: Change asyncio.AbstractEventLoop.run_in_executor to be a method ↵James Weaver2020-08-171-1/+1
| | | | | | not a coroutine (GH-21852) asyncio.AbstractEventLoop.run_in_executor should be a method that returns an asyncio Future, not an async method. This matches the concrete implementations, and the documentation better.
* bpo-41467: Fix asyncio recv_into() on Windows (GH-21720)Victor Stinner2020-08-041-1/+1
| | | | | On Windows, fix asyncio recv_into() return value when the socket/pipe is closed (BrokenPipeError): return 0 rather than an empty byte string (b'').
* bpo-41317: Remove reader on cancellation in asyncio.loop.sock_accept() (#21595)Alex Grönholm2020-07-231-7/+6
|
* bpo-37703: improve asyncio.gather documentation regarding cancellation ↵Vinay Sharma2020-07-201-0/+7
| | | | | | | (GH-15312) These changes updates the doc to comprehensively mention the behaviour of gather.cancel() Automerge-Triggered-By: @asvetlov
* bpo-41273: asyncio's proactor read transport's better performance by using ↵Tony Solomonik2020-07-141-19/+21
| | | | | | | | | | | | | | | recv_into instead of recv (#21442) * bpo-41273: Proactor transport read loop to use recv_into By using recv_into instead of recv we do not allocate a new buffer each time _loop_reading calls recv. This betters performance for any stream using proactor (basically any asyncio stream on windows). * bpo-41273: Double proactor read transport buffer size By doubling the read buffer size we get better performance.
* bpo-40967: Remove deprecated asyncio.Task.current_task() and ↵Rémi Lapeyre2020-07-021-28/+0
| | | | asyncio.Task.all_tasks() (GH-20874)
* Fix asyncio.to_thread() documented return type (GH-20547)Kyle Stanley2020-05-311-1/+1
| | | | | When I wrote the documentation for `asyncio.to_thread()`, I mistakenly assumed that `return await loop.run_in_executor(...)` within an async def function would return a Future. In reality, it returns a coroutine. This likely won't affect typical usage of `asyncio.to_thread()`, but it's important for the documentation to be correct here. In general, we also tend to avoid returning futures from high-level APIs in asyncio.
* bpo-30064: Fix asyncio loop.sock_* race condition issue (#20369)Fantix King2020-05-271-16/+25
|
* bpo-32309: Add support for contextvars in asyncio.to_thread() (GH-20278)Kyle Stanley2020-05-211-2/+6
| | | | | Allows contextvars from the main thread to be accessed in the separate thread used in `asyncio.to_thread()`. See the [discussion](https://github.com/python/cpython/pull/20143#discussion_r427808225) in GH-20143 for context. Automerge-Triggered-By: @aeros
* s/wakup/wakeup (GH-20250)Kunal Bhalla2020-05-201-1/+1
| | | | | (as title) Automerge-Triggered-By: @Mariatta
* bpo-32309: Implement asyncio.to_thread() (GH-20143)Kyle Stanley2020-05-192-0/+23
| | | | | Implements `asyncio.to_thread`, a coroutine for asynchronously running IO-bound functions in a separate thread without blocking the event loop. See the discussion starting from [here](https://github.com/python/cpython/pull/18410#issuecomment-628930973) in GH-18410 for context. Automerge-Triggered-By: @aeros
* bpo-31033: Improve the traceback for cancelled asyncio tasks (GH-19951)Chris Jerdonek2020-05-182-19/+33
| | | | | When an asyncio.Task is cancelled, the exception traceback now starts with where the task was first interrupted. Previously, the traceback only had "depth one."
* bpo-31033: Add a msg argument to Future.cancel() and Task.cancel() (GH-19979)Chris Jerdonek2020-05-153-19/+36
|
* bpo-40607: Reraise exception during task cancelation in asyncio.wait_for() ↵romasku2020-05-151-1/+9
| | | | | | | | | | | | | | | (GH-20054) Currently, if asyncio.wait_for() timeout expires, it cancels inner future and then always raises TimeoutError. In case those future is task, it can handle cancelation mannually, and those process can lead to some other exception. Current implementation silently loses thoses exception. To resolve this, wait_for will check was the cancelation successfull or not. In case there was exception, wait_for will reraise it. Co-authored-by: Roman Skurikhin <roman.skurikhin@cruxlab.com>
* bpo-40443: Remove unused imports in the stdlib (GH-19803)Victor Stinner2020-04-302-2/+0
|
* Fix typo from Lib/asyncio/events.py (GH-19410)Galden2020-04-141-1/+1
|
* bpo-39764: Make Task.get_stack accept ag_frame (#18669)Lidi Zheng2020-03-021-3/+10
| | | | Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* bpo-39609: set the thread_name_prefix for the default asyncio executor ↵Markus Mohrhard2020-02-271-1/+3
| | | | | (GH-18458) Just a small debugging improvement to identify the asyncio executor threads.
* bpo-34793: Drop old-style context managers in asyncio.locks (GH-17533)Andrew Svetlov2020-02-011-83/+0
|
* bpo-38356: Fix ThreadedChildWatcher thread leak in test_asyncio (GH-16552)Kyle Stanley2020-01-121-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation for this PR (comment from @vstinner in bpo issue): ``` Warning seen o AMD64 Ubuntu Shared 3.x buildbot: https://buildbot.python.org/all/#/builders/141/builds/2593 test_devnull_output (test.test_a=syncio.test_subprocess.SubprocessThreadedWatcherTests) ... Warning -- threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 2) ``` The following implementation details for the new method are TBD: 1) Public vs private 2) Inclusion in `close()` 3) Name 4) Coroutine vs subroutine method 5) *timeout* parameter If it's a private method, 3, 4, and 5 are significantly less important. I started with the most minimal implementation that fixes the dangling threads without modifying the regression tests, which I think is particularly important. I typically try to avoid directly modifying existing tests as much as possible unless it's necessary to do so. However, I am open to changing any part of this. https://bugs.python.org/issue38356
* bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863)Andrew Svetlov2020-01-071-3/+3
| | | https://bugs.python.org/issue39191
* Fix #39191: Don't spawn a task before failing (#17796)Andrew Svetlov2020-01-041-3/+7
|
* bpo-34790: Implement deprecation of passing coroutines to asyncio.wait() ↵Kyle Stanley2019-12-301-0/+6
| | | | (GH-16977)
* Fix import path for asyncio.TimeoutError (#17691)Andrew Svetlov2019-12-241-2/+2
|
* bpo-37228: Fix loop.create_datagram_endpoint()'s usage of SO_REUSEADDR (#17311)Kyle Stanley2019-12-091-7/+18
|
* bpo-39006: Fix asyncio when the ssl module is missing (GH-17524)Victor Stinner2019-12-091-10/+10
| | | | Fix asyncio when the ssl module is missing: only check for ssl.SSLSocket instance if the ssl module is available.
* bpo-37404: Raising value error if an SSLSocket is passed to asyncio ↵idomic2019-12-071-0/+10
| | | | | functions (GH-16457) https://bugs.python.org/issue37404
* bpo-38529: Fix asyncio stream warning (GH-17474)Andrew Svetlov2019-12-071-18/+1
|
* bpo-38978: Implement __class_getitem__ for asyncio objects (GH-17491)Batuhan Taşkaya2019-12-073-0/+9
| | | https://bugs.python.org/issue38978