summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-113892: Add a extra check to `ProactorEventLoop.sock_connect` to ↵Miss Islington (bot)2024-06-011-0/+2
| | | | | | | ensure that the given socket is in non-blocking mode (GH-119519) (#119912) (cherry picked from commit cf3bba3f0671d2c9fee099e3ab0f78b98b176131) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* [3.13] gh-118894: Make asyncio REPL use pyrepl (GH-119433) (#119884)Miss Islington (bot)2024-05-311-18/+71
| | | | | (cherry picked from commit 2237946af0981c46dc7d3886477e425ccfb37f28) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.13] gh-119121: Fix and test `async.staggered.staggered_race` (GH-119173) ↵Miss Islington (bot)2024-05-201-2/+1
| | | | | | | | (#119206) gh-119121: Fix and test `async.staggered.staggered_race` (GH-119173) (cherry picked from commit 16b46ebd2b0025aa461fdfc95fbf98a4f04b49e6) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.13] gh-118817: Fix `asyncio REPL` on Windows (GH-118819) (#118847)Miss Islington (bot)2024-05-091-3/+4
| | | | | (cherry picked from commit c3643a121401d111bebd3e26d6f362ade2ed2a83) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* gh-117722: Fix Stream.readuntil with non-bytes buffer objects (#117723)Bruce Merry2024-04-111-5/+5
| | | | | | | | | | | | | gh-16429 introduced support for an iterable of separators in Stream.readuntil. Since bytes-like types are themselves iterable, this can introduce ambiguities in deciding whether the argument is an iterator of separators or a singleton separator. In gh-16429, only 'bytes' was considered a singleton, but this will break code that passes other buffer object types. Fix it by only supporting tuples rather than arbitrary iterables. Closes gh-117722.
* gh-116720: Fix corner cases of taskgroups (#117407)Guido van Rossum2024-04-092-6/+15
| | | | | | | | | | This prevents external cancellations of a task group's parent task to be dropped when an internal cancellation happens at the same time. Also strengthen the semantics of uncancel() to clear self._must_cancel when the cancellation count reaches zero. Co-Authored-By: Tin Tvrtković <tinchester@gmail.com> Co-Authored-By: Arthur Tacca
* gh-81322: support multiple separators in StreamReader.readuntil (#16429)Bruce Merry2024-04-081-21/+44
|
* gh-96471: Correct documentation for asyncio queue shutdown (#117621)Laurie O2024-04-081-2/+4
|
* gh-96471: Add asyncio queue shutdown (#104228)Laurie O2024-04-061-3/+65
| | | Co-authored-by: Duprat <yduprat@gmail.com>
* gh-117459: Keep the traceback in _convert_future_exc (#117460)rsp4jack2024-04-041-4/+2
|
* gh-77714: Provide an async iterator version of as_completed (GH-22491)Justin Turner Arthur2024-04-011-44/+108
| | | | | | | | | * as_completed returns object that is both iterator and async iterator * Existing tests adjusted to test both the old and new style * New test to ensure iterator can be resumed * New test to ensure async iterator yields any passed-in Futures as-is Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (#32011)Erik Soma2024-03-231-12/+17
|
* gh-116773: Ensure overlapped objects on Windows are not deallocated too ↵jkriegshauser2024-03-201-7/+7
| | | | early by asyncio (GH-116774)
* gh-113538: Add asycio.Server.{close,abort}_clients (redo) (#116784)Pierre Ossman (ThinLinc team)2024-03-184-12/+31
| | | | | | | These give applications the option of more forcefully terminating client connections for asyncio servers. Useful when terminating a service and there is limited time to wait for clients to finish up their work. This is a do-over with a test fix for gh-114432, which was reverted.
* gh-113538: Revert "gh-113538: Add asycio.Server.{close,abort}_clients ↵Guido van Rossum2024-03-124-31/+12
| | | | | | | | | | (#114432)" (#116632) Revert "gh-113538: Add asycio.Server.{close,abort}_clients (#114432)" Reason: The new test doesn't always pass: https://github.com/python/cpython/pull/116423#issuecomment-1989425489 This reverts commit 1d0d49a7e86257ff95b4de0685e6997d7533993c.
* gh-113538: Add asycio.Server.{close,abort}_clients (#114432)Pierre Ossman (ThinLinc team)2024-03-114-12/+31
| | | | | | These give applications the option of more forcefully terminating client connections for asyncio servers. Useful when terminating a service and there is limited time to wait for clients to finish up their work.
* gh-115957: Close coroutine if TaskGroup.create_task() raises an error (#116009)Jason Zhang2024-03-061-0/+3
|
* chore: fix typos (#116345)cui fliter2024-03-051-1/+1
| | | Signed-off-by: cui fliter <imcusg@gmail.com>
* gh-84995: Run sys.__interactivehook__() on asyncio REPL startup (#20517)Rémi Lapeyre2024-03-011-0/+16
| | | | | | | | | | This makes the asyncio REPL (`python -m asyncio`) more usable and similar to the regular REPL. This exposes register_readline() as a top-level function in site.py, but it's intentionally undocumented. Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Itamar Oren <itamarost@gmail.com>
* gh-112997: Don't log arguments in asyncio unless debugging (#115667)Pierre Ossman (ThinLinc team)2024-02-282-9/+19
| | | | | | Nothing else in Python generally logs the contents of variables, so this can be very unexpected for developers and could leak sensitive information in to terminals and log files.
* gh-114914: Avoid keeping dead StreamWriter alive (#115661)Pierre Ossman (ThinLinc team)2024-02-281-10/+4
| | | | | | | | | | In some cases we might cause a StreamWriter to stay alive even when the application has dropped all references to it. This prevents us from doing automatical cleanup, and complaining that the StreamWriter wasn't properly closed. Fortunately, the extra reference was never actually used for anything so we can just drop it.
* gh-111358: Fix timeout behaviour in BaseEventLoop.shutdown_default_executor ↵Jamie Phan2024-02-191-9/+11
| | | | (#115622)
* gh-113812: Allow DatagramTransport.sendto to send empty data (#115199)Jamie Phan2024-02-173-7/+4
| | | | Also include the UDP packet header sizes (8 bytes per packet) in the buffer size reported to the flow control subsystem.
* gh-114887 Reject only sockets of type SOCK_STREAM in ↵Travis Howse2024-02-031-2/+2
| | | | | | | create_datagram_endpoint() (#114893) Also improve exception message. Co-authored-by: Donghee Na <donghee.na92@gmail.com>
* gh-112202: Ensure that condition.notify() succeeds even when racing with ↵Kristján Valur Jónsson2024-02-031-49/+63
| | | | | Task.cancel() (#112201) Also did a general cleanup of asyncio locks.py comments and docstrings.
* gh-109534: fix reference leak when SSL handshake fails (#114074)Jamie Phan2024-02-012-0/+5
|
* TaskGroup: Use explicit None check for cancellation error (#114708)Matan Perelman2024-01-291-1/+1
|
* gh-75128: Ignore EADDRNOTAVAIL error in ↵Serhiy Storchaka2024-01-221-3/+17
| | | | | asyncio.BaseEventLoop.create_server() (GH-114420) Co-authored-by: Antoine Pitrou <pitrou@free.fr>
* gh-114281: Remove incorrect type hints from `asyncio.staggered` (#114282)Nikita Sobolev2024-01-201-11/+1
| | | Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* gh-95649: Document that asyncio contains uvloop code (#107536)Alois Klink2024-01-123-0/+12
| | | | | | | | Some of the asyncio SSL changes in GH-31275 [1] were taken from v0.16.0 of the uvloop project [2]. In order to comply with the MIT license, we need to just need to document the copyright information. [1]: https://github.com/python/cpython/pull/31275 [2]: https://github.com/MagicStack/uvloop/tree/v0.16.0
* gh-96037: Always insert TimeoutError when exit an expired asyncio.timeout() ↵Serhiy Storchaka2024-01-101-2/+17
| | | | | | | | block (GH-113819) If other exception was raised during exiting an expired asyncio.timeout() block, insert TimeoutError in the exception context just above the CancelledError.
* gh-112182: Replace StopIteration with RuntimeError for future (#113220)Jamie Phan2024-01-101-3/+7
| | | | | | When an `StopIteration` raises into `asyncio.Future`, this will cause a thread to hang. This commit address this by not raising an exception and silently transforming the `StopIteration` with a `RuntimeError`, which the caller can reconstruct from `fut.exception().__cause__`
* gh-113848: Handle CancelledError subclasses in asyncio TaskGroup() and ↵Serhiy Storchaka2024-01-092-7/+10
| | | | timeout() (GH-113850)
* GH-111693: Propagate correct asyncio.CancelledError instance out of ↵Kristján Valur Jónsson2024-01-082-25/+39
| | | | | asyncio.Condition.wait() (#111694) Also fix a race condition in `asyncio.Semaphore.acquire()` when cancelled.
* gh-113538: Don't error in stream reader protocol callback when task is ↵Guido van Rossum2024-01-041-0/+3
| | | | cancelled (#113690)
* gh-112800: Ignore PermissionError on SubprocessTransport.close() in asyncio ↵Allison Karlitskaya2023-12-241-1/+2
| | | | | | | | | | (#112803) In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
* GH-113214: Fix SSLProto exception handling in SSL-over-SSL scenarios (#113334)Martijn Pieters2023-12-201-7/+6
| | | | | | When wrapped, `_SSLProtocolTransport._force_close(exc)` is called just like in the unwrapped scenario `_SelectorTransport._force_close(exc)` or `_ProactorBasePipeTransport._force_close(exc)` would be called, except here the exception needs to be passed through the `SSLProtocol._abort()` method, which didn't accept an exception object. This commit ensures that this path works, in the same way that the uvloop implementation of SSLProto passes on the exception (on which the current implementation of SSLProto is based).
* gh-101336: Add keep_alive keyword arg for asyncio create_server() (#112485)beavailable2023-12-132-0/+8
|
* gh-112622: Pass name to loop create_task method (#112623)Jamie2023-12-132-6/+5
| | | This affects task creation through either `asyncio.create_task()` or `TaskGroup.create_task()` -- the redundant call to `task.set_name()` is skipped. We still call `set_name()` when a task factory is involved, because the task factory call signature (unfortunately) doesn't take a `name` argument.
* gh-112989: asyncio: Reduce overhead to connect sockets with ↵J. Nick Koston2023-12-131-9/+5
| | | | | | SelectorEventLoop (#112991) _ensure_fd_no_transport had a KeyError in the success path
* gh-109538: Avoid RuntimeError when StreamWriter is deleted with closed loop ↵DPR2023-11-151-3/+5
| | | | | | | (#111983) Issue a ResourceWarning instead. Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* gh-111246: Remove listening Unix socket on close (#111483)Pierre Ossman (ThinLinc team)2023-11-081-1/+32
| | | | | Try to clean up the socket file we create so we don't add unused noise to the file system.
* GH-110894: Call loop exception handler for exceptions in client_connected_cb ↵Kumar Aditya2023-11-021-0/+12
| | | | | (#111601) Call loop exception handler for exceptions in `client_connected_cb` of `asyncio.start_server` so that applications can handle it.
* gh-79033: Try to fix asyncio.Server.wait_closed() again (GH-111336)Guido van Rossum2023-10-281-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Try to fix asyncio.Server.wait_closed() again I identified the condition that `wait_closed()` is intended to wait for: the server is closed *and* there are no more active connections. When this condition first becomes true, `_wakeup()` is called (either from `close()` or from `_detach()`) and it sets `_waiters` to `None`. So we just check for `self._waiters is None`; if it's not `None`, we know we have to wait, and do so. A problem was that the new test introduced in 3.12 explicitly tested that `wait_closed()` returns immediately when the server is *not* closed but there are currently no active connections. This was a mistake (probably a misunderstanding of the intended semantics). I've fixed the test, and added a separate test that checks exactly for this scenario. I also fixed an oddity where in `_wakeup()` the result of the waiter was set to the waiter itself. This result is not used anywhere and I changed this to `None`, to avoid a GC cycle. * Update Lib/asyncio/base_events.py --------- Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
* gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (#110884)Guido van Rossum2023-10-271-9/+2
| | | | | - `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything. - Threads created by that class are now named `asyncio-waitpid-NNN`. - `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
* gh-111085: Fix invalid state handling in TaskGroup and Timeout (#111111)Serhiy Storchaka2023-10-212-8/+10
| | | | | | | | | | | | | | | | asyncio.TaskGroup and asyncio.Timeout classes now raise proper RuntimeError if they are improperly used. * When they are used without entering the context manager. * When they are used after finishing. * When the context manager is entered more than once (simultaneously or sequentially). * If there is no current task when entering the context manager. They now remain in a consistent state after an exception is thrown, so subsequent operations can be performed correctly (if they are allowed). Co-authored-by: James Hilton-Balfe <gobot1234yt@gmail.com>
* gh-110961: Fixed asyncio.wait docstring to remove deprecated coroutine ↵Bar Harel2023-10-181-2/+0
| | | | | reference (#111017) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* remove redundant call to attach_loop in watcher (#110847)Thomas Grainger2023-10-141-2/+0
|
* gh-110771: Decompose run_forever() into parts (#110773)Russell Keith-Magee2023-10-132-31/+57
| | | Effectively introduce an unstable, private (really: protected) API for subclasses that want to override `run_forever()`.
* gh-94597: Add asyncio.EventLoop (#110723)Thomas Grainger2023-10-122-1/+4
| | | This is needed to pave the way for deprecating and eventually killing the event loop policy system (which is over-engineered and rarely used).