Commit Graph

940 Commits

Author SHA1 Message Date
Łukasz Langa d542a9be51
[3.11] gh-121957: Emit audit events for python -i and python -m asyncio (GH-122118) 2024-07-22 13:44:55 +02:00
Serhiy Storchaka 6261322e26
[3.11] gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (GH-32011) (GH-117210)
(cherry picked from commit f11d0d8be8)

Co-authored-by: Erik Soma <stillusingirc@gmail.com>
2024-03-25 10:34:25 +00:00
jkriegshauser 23a1c9f422
[3.11] gh-116773: Fix overlapped memory corruption crash (GH-116774) (#117077)
Manual backport of gh-116774.
2024-03-20 13:10:32 -07:00
Travis Howse 5ce076fd92
[3.11] gh-114887 Reject only sockets of type SOCK_STREAM in create_da… (#114979)
Also improve exception message.

(cherry picked from commit 94ec2b9c9c)

Co-authored-by: Donghee Na <donghee.na92@gmail.com>
2024-02-04 20:01:37 -08:00
Miss Islington (bot) ef2ba9a007
[3.11] gh-109534: fix reference leak when SSL handshake fails (GH-114074) (#114830)
gh-109534: fix reference leak when SSL handshake fails (GH-114074)
(cherry picked from commit 80aa7b3688)

Co-authored-by: Jamie Phan <jamie@ordinarylab.dev>
2024-02-01 00:59:17 +00:00
Miss Islington (bot) acea9d8e87
[3.11] gh-75128: Ignore EADDRNOTAVAIL error in asyncio.BaseEventLoop.create_server() (GH-114420) (GH-114442)
(cherry picked from commit a53e56e7d8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2024-01-22 17:20:01 +00:00
Alois Klink 0d12a64eaf
[3.11] gh-95649: Document that asyncio contains uvloop code (GH-107536) (#114045)
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

(cherry picked from commit dce30c9cbc)
2024-01-14 02:14:51 +00:00
Miss Islington (bot) 456e2ecdd2
[3.11] gh-113538: Don't error in stream reader protocol callback when task is cancelled (GH-113690) (#113714)
(cherry picked from commit 4681a5271a)

Co-authored-by: Guido van Rossum <guido@python.org>
2024-01-04 20:39:52 +00:00
Miss Islington (bot) 9cbe4738bc
[3.11] GH-113214: Fix SSLProto exception handling in SSL-over-SSL scenarios (GH-113334) (#113340)
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).

(cherry picked from commit 1ff0238594)

Co-authored-by: Martijn Pieters <mj@zopatista.com>
2023-12-20 16:51:51 -08:00
DPR 13975051b5
[3.11] gh-109538: Catch closed loop runtime error and issue warning (GH-111983) (#112141)
Issue a ResourceWarning instead.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
(cherry picked from commit e0f5127975)
2023-11-20 15:12:17 -08:00
Miss Islington (bot) f7ffe4a8ea
[3.11] [3.12] GH-110894: Call loop exception handler for exceptions in client_connected_cb (GH-111601) (GH-111632) (#111634)
* [3.12] GH-110894: Call loop exception handler for exceptions in client_connected_cb (GH-111601) (GH-111632)
(cherry picked from commit 9aa88290d8)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Call loop exception handler for exceptions in `client_connected_cb` of `asyncio.start_server` so that applications can handle it..
(cherry picked from commit 229f44d353)

* gh-111644: Fix asyncio test_unhandled_exceptions() (#111713)

Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.

Fix also StreamTests.tearDown(): the loop must not be closed
explicitly, but using set_event_loop() which takes care of shutting
down the executor with executor.shutdown(wait=True).
BaseEventLoop.close() calls executor.shutdown(wait=False).

(cherry picked from commit ac01e2243a)

---------

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-11-04 01:23:01 +00:00
Miss Islington (bot) 1a01ca44d6
[3.11] gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (GH-110884) (#111413)
- `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`.
(cherry picked from commit c3bb10c930)

Co-authored-by: Guido van Rossum <guido@python.org>
2023-10-27 16:36:24 -07:00
Miss Islington (bot) cf777399a9
[3.11] gh-111085: Fix invalid state handling in TaskGroup and Timeout (GH-111111) (GH-111172)
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).

(cherry picked from commit 6c23635f2b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: James Hilton-Balfe <gobot1234yt@gmail.com>
2023-10-21 19:40:07 +00:00
Thomas Grainger fd1b314cd3
[3.11] remove redundant call to attach_loop in watcher (GH-110847) (#110870)
(cherry picked from commit 596589104f)
2023-10-15 14:51:13 +00:00
Miss Islington (bot) 4b97c724e0
[3.11] gh-109955 : Update state transition comments for asyncio.Task (GH-109910) (#109993)
gh-109955 : Update state transition comments for asyncio.Task (GH-109910)
(cherry picked from commit 45cf5b0c69)

Co-authored-by: Kristján Valur Jónsson <sweskman@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-09-29 15:25:34 +02:00
Miss Islington (bot) 0a69de7687
[3.11] Remove loop from docstring for asyncio.streams.open_connection (GH-108528) (#109942)
Remove loop from docstring for asyncio.streams.open_connection (GH-108528)
(cherry picked from commit e721f7a951)

Co-authored-by: Tom Gillespie <tgbugs@gmail.com>
2023-09-27 09:18:25 +03:00
Victor Stinner 1629b1d6f9
[3.11] gh-109709: Fix asyncio test_stdin_broken_pipe() (#109710) (#109735)
gh-109709: Fix asyncio test_stdin_broken_pipe() (#109710)

Replace harcoded sleep of 500 ms with synchronization using a pipe.

Fix also Process._feed_stdin(): catch also BrokenPipeError on
stdin.write(input), not only on stdin.drain().

(cherry picked from commit cbbdf2c144)
2023-09-22 14:34:53 +00:00
Miss Islington (bot) fb08b7905e
[3.11] [3.12] GH-106684: Close `asyncio.StreamWriter` when `asyncio.StreamWriter` is not closed by application (GH-107650) (GH-107656) (#107836)
[3.12] GH-106684:  Close `asyncio.StreamWriter` when `asyncio.StreamWriter` is not closed by application (GH-107650) (GH-107656)

GH-106684: raise `ResourceWarning` when `asyncio.StreamWriter` is not closed (GH-107650)
(cherry picked from commit 41178e4199)

(cherry picked from commit 7853c76906)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-08-10 16:14:31 +05:30
Miss Islington (bot) ddccdbfc40
[3.11] gh-106634: Corrected minor asyncio doc issues (GH-106671) (#106711)
gh-106634: Corrected minor asyncio doc issues (GH-106671)
(cherry picked from commit 4b4a5b70aa)

Co-authored-by: Chris Brett <chrisbrett665@gmail.com>
2023-07-29 18:07:49 +00:00
Miss Islington (bot) a8fc8b7e81
[3.11] gh-104340: Suppress warning about unawaited exception for closed pipe stdin (GH-104586) (#104594)
(cherry picked from commit 7fc8e2d462)

Co-authored-by: Guido van Rossum <guido@python.org>
2023-05-18 00:09:12 +00:00
Miss Islington (bot) 1afc0a9591
[3.11] gh-98539: Make _SSLTransportProtocol.abort() safe to call when closed (GH-104474) (#104485)
(cherry picked from commit fb8739f0b6)

Co-authored-by: Sam Bull <git@sambull.org>
2023-05-14 21:24:07 +00:00
Miss Islington (bot) 2cd1b9c2ca
[3.11] gh-103607: Fix `pause_reading` to work when called from `connection_made` in `asyncio`. (GH-17425) (#103918)
gh-103607: Fix `pause_reading` to work when called from `connection_made` in `asyncio`. (GH-17425)
(cherry picked from commit 78942ecd9b)

Co-authored-by: Itayazolay <itayazolay@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-04-27 10:29:54 +00:00
Miss Islington (bot) a9ece4a839
gh-102780: Fix uncancel() call in asyncio timeouts (GH-102815)
Also use `raise TimeOut from <CancelledError instance>` so that the CancelledError is set
in the `__cause__` field rather than in the `__context__` field.

(cherry picked from commit 04adf2df39)

Co-authored-by: Kristján Valur Jónsson <sweskman@gmail.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-22 11:23:47 -07:00
Miss Islington (bot) 98833563e2
gh-102810: Add docstrings to the public-facing methods of `asyncio.Timeout` (GH-102811)
(cherry picked from commit 699cb20ae6)

Co-authored-by: JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-19 13:31:22 -07:00
Miss Islington (bot) 7e5ba351e0
gh-102560 Add docstrings to asyncio.TaskGroup (GH-102565)
(cherry picked from commit e94edab727)

Co-authored-by: JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com>
2023-03-15 00:27:33 -07:00
Miss Islington (bot) 42d0ca92ed
[3.11] gh-100226: Clarify StreamReader.read behavior (GH-101807) (#102001)
gh-100226: Clarify StreamReader.read behavior (GH-101807)
(cherry picked from commit 77d95c8373)

Co-authored-by: Jan Gosmann <jan@hyper-world.de>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-02-23 19:05:59 +05:30
Miss Islington (bot) 99da75e770
gh-101143: Remove references to `TimerHandle` from `asyncio.base_events.BaseEventLoop._add_callback` (GH-101197)
(cherry picked from commit 9e947675ae)

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-01-21 02:28:09 -08:00
Miss Islington (bot) d06315a6fa
[3.11] GH-100573: Fix server hang caused by os.stat() on named pipe (Windows) (GH-100959) (#101019)
(cherry picked from commit 1bc7a73683)
2023-01-13 13:58:20 -08:00
Serhiy Storchaka 1b2459dc64
[3.11] gh-100160: Remove any deprecation warnings in asyncio.get_event_loop() (#100412)
Some deprecation warnings will reappear (in a slightly different form) in 3.12.

Co-authored-by: Guido van Rossum <guido@python.org>
2023-01-10 12:20:09 -08:00
Miss Islington (bot) ad40764f5b
GH-86508: skip binding to local addresses of different family in `asyncio.open_connection` (GH-100615)
(cherry picked from commit ba8dcdbcab)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-01-04 00:28:00 -08:00
Miss Islington (bot) ae8520c709
GH-100133: fix `asyncio` subprocess losing `stderr` and `stdout` output (GH-100154)
(cherry picked from commit a7715ccfba)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-12-21 02:24:19 -08:00
Serhiy Storchaka 3fae04b10e
[3.11] gh-93453: Only emit deprecation warning in asyncio.get_event_loop when a new event loop is created (#99949)
It no longer emits a deprecation warning if the current event loop was set.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-12-06 16:15:44 +01:00
Dong Uk, Kang 24fad64cef
[3.11] gh-88863: Clear ref cycles to resolve leak when asyncio.open_connection raises (GH-95739) (#99721)
Break reference cycles to resolve memory leak, by
removing local exception and future instances from the frame.
(cherry picked from commit 995f6170c7)

Co-authored-by: Dong Uk, Kang <nailbrainz@gmail.com>
2022-11-23 10:37:24 -08:00
Miss Islington (bot) 0dfbb769df
[3.11] gh-99277: remove older version of `get_write_buffer_limits` (GH-99280) (#99338)
(cherry picked from commit f1680c3fbf)

Co-authored-by: Carlo <34414634+csuriano23@users.noreply.github.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-11-10 09:01:14 -08:00
Miss Islington (bot) 08ce791f94
gh-98703: Fix asyncio proactor_events calling _call_connection_lost multiple times (GH-98704)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
(cherry picked from commit 8a755423eb)

Co-authored-by: Ken Jin <kenjin@python.org>
2022-10-26 20:04:43 -07:00
Miss Islington (bot) 8950689dce
[3.11] GH-89237: fix hang in proactor `subprocess.wait_closed()` (GH-98572) (#98620)
GH-89237: fix hang in proactor `subprocess.wait_closed()` (GH-98572)
(cherry picked from commit ad1dc3ebb6)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-24 20:34:08 -07:00
Miss Islington (bot) 36d25a4f7f
[3.11] GH-98543: Fix `asyncio.TaskGroup` to not keep reference to errors after raising ExceptionGroup (GH-98544) (#98550)
GH-98543: Fix `asyncio.TaskGroup`  to not keep reference to errors after raising ExceptionGroup  (GH-98544)
(cherry picked from commit f4a14941e6)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-24 11:08:22 -07:00
Miss Islington (bot) bd8b32b519
[3.11] GH-98539: fix ref cycle in `_SSLProtocolTransport` after close (GH-98540) (#98551)
GH-98539: fix ref cycle in `_SSLProtocolTransport` after close  (GH-98540)
(cherry picked from commit 62bf5d8d0a)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-24 09:26:32 -07:00
Miss Islington (bot) 595ef03c7c
bpo-46364: Use sockets for stdin of asyncio only on AIX (GH-30596)
Signed-off-by: Christoph Hamsen <hamsen.christoph@posteo.de>
Co-authored-by: July Tikhonov <july.tikh@gmail.com>
(cherry picked from commit c9ed0327a9)

Co-authored-by: Christoph Hamsen <37963496+xopham@users.noreply.github.com>
2022-10-13 10:27:31 -07:00
Miss Islington (bot) d163d5976d
GH-90985: Revert "Deprecate passing a message into cancel()" (GH-97999)
Reason: we were too hasty in deprecating this.
We shouldn't deprecate it before we have a replacement.
(cherry picked from commit 09de8d7aaf)

Co-authored-by: Guido van Rossum <guido@python.org>
2022-10-06 18:50:25 -07:00
Miss Islington (bot) bd3dcb3549
[3.11] GH-88050: fix race in closing subprocess pipe in asyncio (GH-97951) (#97978)
Check for None when iterating over `self._pipes.values()`.
(cherry picked from commit e2e6b95c03)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-06 12:09:50 -07:00
Miss Islington (bot) aec133347e
gh-88050: Fix asyncio subprocess to kill process cleanly when process is blocked (GH-32073)
(cherry picked from commit 7015e13797)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-05 10:48:48 -07:00
Miss Islington (bot) 4420da0aef
gh-94732: Fix KeyboardInterrupt race in asyncio run_forever() (GH-97765)
Ensure that the event loop's `_thread_id` attribute and the asyncgen hooks set by `sys.set_asyncgen_hooks()` are always restored no matter where a KeyboardInterrupt exception is raised.
(cherry picked from commit 3a49dbb98c)

Co-authored-by: hetmankp <728670+hetmankp@users.noreply.github.com>
2022-10-03 14:39:24 -07:00
Miss Islington (bot) 3614bbb8eb
gh-90908: Document asyncio.Task.cancelling() and asyncio.Task.uncancel() (GH-95253)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
(cherry picked from commit f00645d5db)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-10-01 11:10:04 -07:00
Miss Islington (bot) 95609525de
GH-96827: Don't touch closed loops from executor threads (GH-96837)
* When chaining futures, skip callback if loop closed.
* When shutting down an executor, don't wake a closed loop.
(cherry picked from commit e9d63760fe)

Co-authored-by: Guido van Rossum <guido@python.org>
2022-09-30 13:23:33 -07:00
Miss Islington (bot) 9a9bf88898
gh-97545: Make Semaphore run faster. (GH-97549)
(cherry picked from commit 68c46ae68b)

Co-authored-by: Cyker Way <cykerway@gmail.com>
2022-09-26 17:00:53 -07:00
Miss Islington (bot) 6642d8a0f9
GH-85760: Fix race in calling process_exited callback too early (GH-97009)
(cherry picked from commit 282edd7b2a)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-09-22 10:24:54 -07:00
Miss Islington (bot) 773dbb9e3a
gh-90155: Fix bug in asyncio.Semaphore and strengthen FIFO guarantee (GH-93222)
The main problem was that an unluckily timed task cancellation could cause
the semaphore to be stuck. There were also doubts about strict FIFO ordering
of tasks allowed to pass.

The Semaphore implementation was rewritten to be more similar to Lock.
Many tests for edge cases (including cancellation) were added.
(cherry picked from commit 24e0379624)

Co-authored-by: Cyker Way <cykerway@gmail.com>
2022-09-22 09:58:35 -07:00
Miss Islington (bot) 335bd1ee8b
gh-94972: document that shield users need to keep a reference to their task (GH-96724)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
(cherry picked from commit 6281affee6)

Co-authored-by: Hendrik Makait <hendrik.makait@gmail.com>
2022-09-10 08:03:35 -07:00
Miss Islington (bot) 2e9f29e6a6
GH-74116: Allow multiple drain waiters for asyncio.StreamWriter (GH-94705) (#96395)
(cherry picked from commit e5b2453e61)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-08-30 12:00:21 +01:00