summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
Commit message (Collapse)AuthorAgeFilesLines
* bpo-42140: Improve asyncio.wait function (GH-22938)Miss Islington (bot)2020-11-101-2/+4
| | | | | | | | | | | | | GH- 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 (cherry picked from commit 7e5ef0a5713f968f6e942566c78bf57ffbef01de) Co-authored-by: Diogo Dutra <diogodutradamata@gmail.com>
* bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() ↵Miss Islington (bot)2020-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> (cherry picked from commit 42d873c63aa9d160c132be4a34599531574db12c) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-42230: Improve asyncio documentation regarding accepting sets vs ↵Miss Skeleton (bot)2020-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.pyiGH-L161 [3] https://github.com/python/typeshed/blob/620989bac572f30349b95590ebe81a73ce0fe862/stdlib/3/asyncio/tasks.pyiGH-L40 (cherry picked from commit 3d86d090dcbbdfdd3e5a5951cab30612d6131222) Co-authored-by: Jakub Stasiak <jakub@stasiak.at>
* bpo-39651: Fix asyncio proactor _write_to_self() (GH-22197)Miss Islington (bot)2020-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. (cherry picked from commit 1b0f0e3d7d03155da1cf9769a847874d559e57e3) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-41696: Fix handling of debug mode in asyncio.run (GH-22069) (#22071)Miss Islington (bot)2020-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> (cherry picked from commit 0770ad948cb6d9f7f6c4002efd83e27c27069808) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* bpo-39010: Fix errors logged on proactor loop restart (GH-22017) (#22034)Miss Islington (bot)2020-09-032-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. (cherry picked from commit ea5a6363c3f8cc90b7c0cc573922b10f296073b6) Co-authored-by: Ben Darnell <ben@bendarnell.com> Co-authored-by: Ben Darnell <ben@bendarnell.com>
* bpo-37658: Fix asyncio.wait_for() to respect waited task status (GH-21894) ↵Miss Islington (bot)2020-08-261-3/+6
| | | | | | | | | | | (GH-21964) 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. (cherry picked from commit a2118a14627256197bddcf4fcecad4c264c1e39d) Co-authored-by: Elvis Pranskevichus <elvis@magic.io>
* bpo-32751: Wait for task cancel in asyncio.wait_for() when timeout <= 0 ↵Miss Islington (bot)2020-08-261-2/+7
| | | | | | | | | | | (GH-21895) (GH-21963) 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. (cherry picked from commit c517fc712105c8e5930cb42baaebdbe37fc3e15f) Co-authored-by: Elvis Pranskevichus <elvis@magic.io>
* bpo-41572: Fix grammar in BaseTransport.close docstring (GH-21914) (#21929)Miss Islington (bot)2020-08-211-2/+2
| | | | | | | | | | Fix grammar in BaseTransport.close docstring. https://bugs.python.org/issue41572 Signed-off-by: Cleber Rosa <crosa@redhat.com> (cherry picked from commit 1afb42cfa82dad0ddd726f59c6c5fcb3962314db) Co-authored-by: Cleber Rosa <cleber.gnu@gmail.com>
* bpo-40782: Change asyncio.AbstractEventLoop.run_in_executor to be a method ↵Miss Islington (bot)2020-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. (cherry picked from commit 29f84294d88ec493c2de9d6e8dbc12fae3778771) Co-authored-by: James Weaver <james.barrett@bbc.co.uk>
* bpo-41467: Fix asyncio recv_into() on Windows (GH-21720)Miss Islington (bot)2020-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''). (cherry picked from commit 602a971a2af3a685d625c912c400cadd452718b1) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-41317: Remove reader on cancellation in asyncio.loop.sock_accept() ↵Miss Islington (bot)2020-07-231-7/+6
| | | | | | | (GH-21595) (cherry picked from commit 0dd98c2d00a75efbec19c2ed942923981bc06683) Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
* bpo-37703: improve asyncio.gather documentation regarding cancellation ↵Miss Islington (bot)2020-07-201-0/+7
| | | | | | | | | | (GH-15312) These changes updates the doc to comprehensively mention the behaviour of gather.cancel() Automerge-Triggered-By: @asvetlov (cherry picked from commit d42528a3a2c7d79fd2e6c9f2a02f3ce12d44c8cc) Co-authored-by: Vinay Sharma <vinay04sharma@icloud.com>
* bpo-40967: Remove deprecated asyncio.Task.current_task() and ↵Miss Islington (bot)2020-07-021-28/+0
| | | | | | | asyncio.Task.all_tasks() (GH-20874) (cherry picked from commit 004e64e8059fe68a72890314673282f2e60d5ce1) Co-authored-by: Rémi Lapeyre <remi.lapeyre@lenstra.fr>
* Fix asyncio.to_thread() documented return type (GH-20547)Miss Islington (bot)2020-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. (cherry picked from commit 2b201369b435a4266bda5b895e3b615dbe28ea6e) Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* bpo-30064: Fix asyncio loop.sock_* race condition issue (GH-20369)Miss Islington (bot)2020-05-271-16/+25
| | | | | (cherry picked from commit 210a137396979d747c2602eeef46c34fc4955448) Co-authored-by: Fantix King <fantix.king@gmail.com>
* bpo-32309: Add support for contextvars in asyncio.to_thread() (GH-20278)Miss Islington (bot)2020-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/20143GH-discussion_r427808225) in GH-20143 for context. Automerge-Triggered-By: @aeros (cherry picked from commit 0f56263e62ba91d0baae40fb98947a3a98034a73) Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* s/wakup/wakeup (GH-20250)Miss Islington (bot)2020-05-201-1/+1
| | | | | | | | (as title) Automerge-Triggered-By: @Mariatta (cherry picked from commit f2947e354c95d246b1836ac78d4c820c420e259b) Co-authored-by: Kunal Bhalla <bhalla.kunal@gmail.com>
* bpo-32309: Implement asyncio.to_thread() (GH-20143)Miss Islington (bot)2020-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/18410GH-issuecomment-628930973) in GH-18410 for context. Automerge-Triggered-By: @aeros (cherry picked from commit cc2bbc2227c3f5ed9d8f6b3bd052e6f9e68279d2) Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* 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
* bpo-38982: Fix asyncio PidfdChildWatcher on waitpid() error (GH-17477)Victor Stinner2019-12-061-2/+13
| | | | | | If waitpid() is called elsewhere, waitpid() call fails with ChildProcessError: use return code 255 in this case, and log a warning. It ensure that the pidfd file descriptor is closed if this error occurs.
* bpo-38951: Use threading.main_thread() check in asyncio (GH-17433)Hill Ma2019-12-052-4/+3
| | | https://bugs.python.org/issue38951
* Remove binding of captured exceptions when not used to reduce the chances of ↵Pablo Galindo2019-11-192-3/+3
| | | | | | | creating cycles (GH-17246) Capturing exceptions into names can lead to reference cycles though the __traceback__ attribute of the exceptions in some obscure cases that have been reported previously and fixed individually. As these variables are not used anyway, we can remove the binding to reduce the chances of creating reference cycles. See for example GH-13135
* bpo-38692: Add asyncio.PidfdChildWatcher to __all__ (GH-17161)Kyle Stanley2019-11-151-1/+1
| | | | | | | | | | /cc @asvetlov @1st1 https://bugs.python.org/issue38692 Automerge-Triggered-By: @benjaminp
* closes bpo-38692: Add a pidfd child process watcher to asyncio. (GH-17069)Benjamin Peterson2019-11-141-0/+67
|
* bpo-38785: Prevent asyncio from crashing (GH-17144)Andrew Svetlov2019-11-131-1/+4
| | | | | | | if parent `__init__` is not called from a constructor of object derived from `asyncio.Future` https://bugs.python.org/issue38785
* bpo-34679: ProactorEventLoop only uses set_wakeup_fd() in main thread (GH-16901)Victor Stinner2019-10-231-3/+3
| | | | bpo-34679, bpo-38563: asyncio.ProactorEventLoop.close() now only calls signal.set_wakeup_fd() in the main thread.
* bpo-34344 Fix AbstractEventLoopPolicy.get_event_loop docstring (GH-16463)idomic2019-10-031-2/+2
|
* Fix and improve `asyncio.run()` docs (GH-16403)Kyle Stanley2019-10-011-5/+1
|
* bpo-38242: Revert "bpo-36889: Merge asyncio streams (GH-13251)" (#16482)Yury Selivanov2019-09-303-1242/+112
| | | See https://bugs.python.org/issue38242 for more details
* bpo-38019: correctly handle pause/resume reading of closed asyncio unix pipe ↵Andrew Svetlov2019-09-291-0/+11
| | | | (GH-16472)
* bpo-38248: Fix inconsistent immediate asyncio.Task cancellation (GH-16330)Yury Selivanov2019-09-251-1/+1
|
* bpo-38260: Add Docs on asyncio.run (GH-16337)Emmanuel Arias2019-09-251-0/+4
| | | | | | | | | | | | | Add docs about return and raise exception on asyncio.run https://bugs.python.org/issue38260 Automerge-Triggered-By: @asvetlov