Commit Graph

1088 Commits

Author SHA1 Message Date
J. Nick Koston 53da1e8c8c
gh-134173: optimize state transfer between `concurrent.futures.Future` and `asyncio.Future` (#134174)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-05-18 21:26:20 +05:30
Sebastian Rittau 1d3eacedb8
gh-133893: asyncio.graph: Replace TextIO annotation with io.Writer (#133894) 2025-05-11 17:59:56 +03:00
Łukasz Langa 60cdd800d9
gh-91048: Add filename:line_no information to `asyncio pstree` (#133478) 2025-05-05 23:07:33 +00:00
Łukasz Langa f610bbdf74
gh-133346: Make theming support in _colorize extensible (GH-133347)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-05-05 23:45:25 +02:00
Thomas Grainger 08d7687094
gh-128307: Support eager_start=<bool> in create_eager_task_factory and various create_task functions (#128306)
Some create_task() functions were changed from `name=None, context=None` to `**kwargs`.

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
2025-05-05 04:58:07 +00:00
Adam Turner 3f80165a26
GH-91048: Minor fixes for ``_remotedebugging`` & rename to ``_remote_debugging`` (#133398) 2025-05-05 02:30:14 +02:00
Pablo Galindo Salgado 3109c47be8
gh-91048: Add filename and line number to external inspection routines (GH-133385)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-05-04 23:33:37 +02:00
Pablo Galindo Salgado 2bc8365231
GH-91048: Add utils for printing the call stack for asyncio tasks (#133284) 2025-05-04 00:51:57 +00:00
Kumar Aditya ce753517a8
gh-86513: improve docs of loop.call_exception_handler (#132466) 2025-04-13 21:39:24 +00:00
Kumar Aditya 05d27a84f4
gh-130322: drop deprecation of `asyncio.set_event_loop` (#132349) 2025-04-12 12:03:52 +05:30
Stan Ulbrych a214db0c54
gh-132307: Remove unnecessary check in `asyncio/base_events.py` (#132324) 2025-04-10 15:41:32 +00:00
Kumar Aditya 94f4d87aeb
gh-131325: fix sendfile fallback implementation to drain data after writing to transport (#131376) 2025-03-18 00:52:57 +05:30
Kumar Aditya 7e3b788e8f
gh-128002: use efficient linked list implementation for eager tasks in asyncio (#130518) 2025-03-03 06:36:43 +00:00
Kumar Aditya 38d45d23a6
gh-129874: avoid mixing pure python and C impl in eager execution (#130515) 2025-02-24 15:37:59 +00:00
Bartosz Sławecki 7ed3dc6392
gh-128231: Use `runcode()` return value for failing early (GH-129488) 2025-02-24 15:50:13 +01:00
Kumar Aditya 660f126f87
gh-129898: per-thread current task implementation in asyncio (#129899)
Store the current running task on the thread state, it makes it thread safe for the free-threading build and while improving performance as there is no lock contention, this effectively makes it lock free.
When accessing the current task of the current running loop in current thread, no locking is required and can be acessed without locking.
In the rare case of accessing current task of a loop running in a different thread, the stop the world pauses is used in free-threading builds to stop all other running threads and find the task for the specified loop.

This also makes it easier for external introspection to find the current task, and now it will be always correct.
2025-02-19 16:34:49 +00:00
Kumar Aditya a545749b0e
gh-130145: fix `loop.run_forever` when loop is already running (#130146) 2025-02-15 15:01:53 +05:30
Kumar Aditya d5796e64e0
gh-129874: avoid mixing pure python and C implementation of asyncio (#129875) 2025-02-09 15:57:00 +05:30
Vojtěch Boček 4e38eeafe2
gh-115514: Fix incomplete writes after close while using ssl in asyncio(#128037)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-02 15:11:25 +00:00
Stan Ulbrych bcb25d60b1
gh-129403: Fix `ValueError` messages in `asyncio.Barrier` and `threading.Barrier` (#129419)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-01-30 11:11:12 +03:00
Thomas Grainger fccbfc40b5
gh-129195: use `future_add_to_awaited_by/future_discard_from_awaited_by` in `asyncio.staggered.staggered_race` (#129253)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-26 21:14:16 +05:30
Thomas Grainger ec91e1c276
gh-128479: fix asyncio staggered race leaking tasks, and logging unhandled exception.append exception (#128475)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-01-23 16:53:53 +01:00
Yury Selivanov 188598851d
GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling (#124640)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Co-authored-by: Jacob Coffee <jacob@z7x.org>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-01-22 17:25:29 +01:00
Thomas Grainger ed6934e71e
gh-128588: gh-128550: remove eager tasks optimization that missed and introduced incorrect cancellations (#129063)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-20 17:13:01 +00:00
Thomas Grainger 38a9956876
gh-128308: pass `**kwargs` to asyncio task_factory (#128768)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-20 22:23:55 +05:30
Michał Górny 3829104ab4
gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets (GH-128933)
* gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets

Do not attempt to set ``SO_REUSEPORT`` on sockets of address familifies other
than ``AF_INET`` and ``AF_INET6``, as it is meaningless with these address
families, and the call with fail with Linux kernel 6.12.9 and newer.

* Apply suggestions from code review

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>

---------

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2025-01-17 16:49:16 -08:00
Wang Ran (汪然) 1a1056d394
Fix typo in `Lib/asyncio/futures.py` (#128819) 2025-01-15 17:54:31 +05:30
Thomas Grainger 61b9811ac6
gh-128552: fix refcycles in eager task creation (#128553) 2025-01-07 11:44:57 +00:00
Michael H 7363476b64
gh-128559: Remove typing import from asyncio.timeouts (#128560) 2025-01-06 15:03:27 -08:00
Kumar Aditya 7e8c571604
gh-128340: add thread safe handle for `loop.call_soon_threadsafe` (#128369)
Adds `_ThreadSafeHandle` to be used for callbacks scheduled with `loop.call_soon_threadsafe`.
2025-01-06 18:05:11 +05:30
jb2170 830e10651b
gh-127529: Correct asyncio's `accept_connection` behaviour for handling `ConnectionAbortedError` (#127532)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-03 10:32:36 +00:00
Andrew Svetlov 0b5f1fae57
Mention loop_factory argument in docstring for asyncio.run() (#128288) 2024-12-27 14:58:35 +01:00
Kumar Aditya 9fce906825
gh-127949: deprecate `asyncio.set_event_loop` (#128218)
Deprecate `asyncio.set_event_loop` to be removed in Python 3.16.
2024-12-24 19:24:28 +05:30
Kumar Aditya a391d80f4b
gh-127949: deprecate asyncio policy classes (#128216) 2024-12-24 17:30:26 +05:30
Kumar Aditya dbd08fb60d
gh-127949: deprecate `asyncio.get_event_loop_policy` (#128053)
This deprecates `asyncio.get_event_loop_policy` and will be removed in Python 3.16.
2024-12-18 18:04:20 +05:30
Kumar Aditya 5892853fb7
gh-127949: deprecate `asyncio.set_event_loop_policy` (#128024)
First step towards deprecating the asyncio policy system.
This deprecates `asyncio.set_event_loop_policy` and will be removed in Python 3.16.
2024-12-18 11:35:29 +05:30
J. Nick Koston e991ac8f20
gh-127655: Ensure `_SelectorSocketTransport.writelines` pauses the protocol if needed (#127656)
Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed. 

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-12-06 10:03:03 +05:30
Kumar Aditya fe5a6ab7be
gh-126353: remove implicit creation of loop from `asyncio.get_event_loop` (#126354)
Remove implicit creation of loop from `asyncio.get_event_loop`. This is a step forward of deprecating the policy system of asyncio.
2024-11-04 14:21:20 +05:30
Javad Shafique 3f24bde0b6
gh-118950: Fix SSLProtocol.connection_lost not being called when OSError is thrown (#118960)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-10-24 17:41:16 +00:00
Thomas Grainger 0b28ea4a35
gh-124958: Revert "gh-125472: Revert "gh-124958: fix asyncio.TaskGroup and _PyFuture refcycles ... (#125486)
* Revert "gh-125472: Revert "gh-124958: fix asyncio.TaskGroup and _PyFuture refcycles (#12… (#125476)"

This reverts commit e99650b80a.

* fix incompatability with gh-124392
2024-10-14 15:45:58 -07:00
Kirill Podoprigora e99650b80a
gh-125472: Revert "gh-124958: fix asyncio.TaskGroup and _PyFuture refcycles (#12… (#125476)
Revert "gh-124958: fix asyncio.TaskGroup and _PyFuture refcycles (#124959)"

This reverts commit d5dbbf4372.
2024-10-14 17:59:13 +00:00
Thomas Grainger d5dbbf4372
gh-124958: fix asyncio.TaskGroup and _PyFuture refcycles (#124959) 2024-10-14 08:19:56 -07:00
Thomas Grainger 979c0df7c0
gh-124309: fix staggered race on eager tasks (#124847)
This patch is entirely by Thomas and Peter

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-10-11 16:31:06 -07:00
Thomas Grainger c066bf5535
gh-124858: fix happy eyeballs refcyles (#124859) 2024-10-02 16:32:31 -07:00
Bartosz Sławecki 67e01a430f
gh-124594: Create and reuse the same context for the entire asyncio REPL session (#124595)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2024-10-01 14:17:22 +00:00
Peter Bierma 133e929a79
gh-124309: Revert eager task factory fix to prevent breaking downstream (#124810)
* Revert "GH-124639: add back loop param to staggered_race (#124700)"

This reverts commit e0a41a5dd1.

* Revert "gh-124309: Modernize the `staggered_race` implementation to support eager task factories (#124390)"

This reverts commit de929f353c.
2024-09-30 18:37:27 -07:00
Kumar Aditya e0a41a5dd1
GH-124639: add back loop param to staggered_race (#124700) 2024-09-29 08:42:46 +05:30
Ron Frederick 1229cb8c14
gh-120284: Enhance `asyncio.run` to accept awaitable objects (#120566)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-09-26 11:45:08 +05:30
Peter Bierma de929f353c
gh-124309: Modernize the `staggered_race` implementation to support eager task factories (#124390)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-09-26 05:11:17 +00:00
Łukasz Langa 033510e11d
gh-120221: Support KeyboardInterrupt in asyncio REPL (#123795)
This switches the main pyrepl event loop to always be non-blocking so that it
can listen to incoming interruptions from other threads.

This also resolves invalid display of exceptions from other threads
(gh-123178).

This also fixes freezes with pasting and an active input hook.
2024-09-06 21:28:29 +02:00