Commit Graph

243 Commits

Author SHA1 Message Date
Miss Islington (bot) d1af4f5372
[3.13] gh-121913: Use str(exc) instead of exc.strerror in `asyncio.base_events` (GH-122269) (#122278)
gh-121913: Use str(exc) instead of exc.strerror in `asyncio.base_events` (GH-122269)
(cherry picked from commit 070f1e2e5b)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2024-07-25 12:20:40 +00:00
Pierre Ossman (ThinLinc team) 4159644177
gh-113538: Add asycio.Server.{close,abort}_clients (redo) (#116784)
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.
2024-03-18 13:15:53 -07:00
Guido van Rossum ba13215eb1
gh-113538: Revert "gh-113538: Add asycio.Server.{close,abort}_clients (#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 1d0d49a7e8.
2024-03-12 00:31:49 +00:00
Pierre Ossman (ThinLinc team) 1d0d49a7e8
gh-113538: Add asycio.Server.{close,abort}_clients (#114432)
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.
2024-03-11 12:43:30 -07:00
Jamie Phan 53d5e67804
gh-111358: Fix timeout behaviour in BaseEventLoop.shutdown_default_executor (#115622) 2024-02-19 00:01:00 +00:00
Travis Howse 94ec2b9c9c
gh-114887 Reject only sockets of type SOCK_STREAM in create_datagram_endpoint() (#114893)
Also improve exception message.

Co-authored-by: Donghee Na <donghee.na92@gmail.com>
2024-02-03 17:14:02 +00:00
Serhiy Storchaka a53e56e7d8
gh-75128: Ignore EADDRNOTAVAIL error in asyncio.BaseEventLoop.create_server() (GH-114420)
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2024-01-22 18:40:35 +02:00
beavailable 3aea6c4823
gh-101336: Add keep_alive keyword arg for asyncio create_server() (#112485) 2023-12-13 03:23:29 +00:00
Guido van Rossum 2655369559
gh-79033: Try to fix asyncio.Server.wait_closed() again (GH-111336)
* 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>
2023-10-28 18:04:29 +00:00
Russell Keith-Magee a7e2a10a85
gh-110771: Decompose run_forever() into parts (#110773)
Effectively introduce an unstable, private (really: protected) API for subclasses that want to override `run_forever()`.
2023-10-13 14:12:32 +00:00
J. Nick Koston 3ac8e6955f
gh-110733: Micro-optimization in BaseEventLoop._run_once (#110735) 2023-10-11 20:59:27 +00:00
Chris Brett 4b4a5b70aa
gh-106634: Corrected minor asyncio doc issues (#106671) 2023-07-13 13:21:13 +05:30
Kumar Aditya 840d02f3f0
GH-105684: Require `asyncio.Task` implementations to support `set_name` method (#105685) 2023-06-13 06:06:40 +00:00
J. Nick Koston 9e947675ae
gh-101143: Remove references to `TimerHandle` from `asyncio.base_events.BaseEventLoop._add_callback` (#101197)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-01-21 14:46:07 +05:30
Kumar Aditya ba8dcdbcab
GH-86508: skip binding to local addresses of different family in `asyncio.open_connection` (#100615) 2023-01-04 13:30:26 +05:30
Guido van Rossum 5d09d11aa0
GH-79033: Fix asyncio.Server.wait_closed() (#98582)
It was a no-op when used as recommended (after close()).

I had to debug one test (test__sock_sendfile_native_failure) --
the cleanup sequence for the test fixture was botched.

Hopefully that's not a portend of problems in user code --
this has never worked so people may well be doing this wrong. :-(

Co-authored-by: kumar aditya
2022-11-24 08:32:58 -07:00
Dong Uk, Kang 995f6170c7
gh-88863: Clear ref cycles to resolve leak when asyncio.open_connection raises (#95739)
Break reference cycles to resolve memory leak, by
removing local exception and future instances from the frame
2022-11-22 07:06:20 -08:00
Guido van Rossum 8079bef56f
GH-96704: Add {Task,Handle}.get_context(), use it in call_exception_handler() (#96756)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-04 23:49:10 -07:00
hetmankp 3a49dbb98c
gh-94732: Fix KeyboardInterrupt race in asyncio run_forever() (#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.
2022-10-03 13:34:35 -07:00
Guido van Rossum e9d63760fe
GH-96827: Don't touch closed loops from executor threads (#96837)
* When chaining futures, skip callback if loop closed.
* When shutting down an executor, don't wake a closed loop.
2022-09-30 12:55:40 -07:00
Kumar Aditya 575a253b5c
GH-82448: Add thread timeout for loop.shutdown_default_executor (#97561)
Co-authored-by: Kyle Stanley <aeros167@gmail.com>
2022-09-28 10:39:42 -07:00
Pamela Fox a0ad63e70e
gh-93973: Add all_errors to asyncio.create_connection (#93974)
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
2022-09-04 18:33:50 -07:00
Alexander Shadchin f882d33778
Fix missing `f` prefix on f-strings (GH-91910) 2022-04-27 09:30:54 +03:00
Andrew Svetlov 9523c0d84f
bpo-46994: Accept explicit contextvars.Context in asyncio create_task() API (GH-31837) 2022-03-14 13:54:13 +02:00
Stefan Zabka da80d6b2f3
bpo-46955: Expose asyncio.base_events.Server as asyncio.Server (GH-31760)
This change aligns the documentation at https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.Server
with the actual implementation

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-08 23:07:33 +02:00
Andrew Svetlov 1f9d4c93af
Raise TypeError if SSLSocket is passed to asyncio transport-based methods (GH-31442) 2022-02-20 14:17:15 +02:00
Kumar Aditya 13c10bfb77
bpo-44011: New asyncio ssl implementation (#31275)
* bpo-44011: New asyncio ssl implementation

Co-Authored-By: Andrew Svetlov <andrew.svetlov@gmail.com>

* fix warning

* fix typo

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-02-15 15:04:00 +02:00
Kumar Aditya a23ab7b6d8
bpo-23819: Fix asyncio tests on python optimized mode (GH-30195) 2021-12-26 13:13:14 +02:00
Jim Crist-Harif f3c16a5e72
Re-add `reuse_address` parameter to `create_server` (GH-29733)
This parameter was accidentally removed when fixing
https://bugs.python.org/issue45129, this reverts the unnecessary changes
there.

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2021-12-12 11:47:01 +02:00
Kumar Aditya 265918bb1d
bpo-23819: asyncio: Replace AssertionError with TypeError where it makes sense (GH-29894) 2021-12-07 01:40:35 +02:00
Hugo van Kemenade 59ea704df7
bpo-45129 Remove deprecated reuse_address (GH-28207)
Due to significant security concerns, the reuse_address parameter of
asyncio.loop.create_datagram_endpoint, deprecated in Python 3.9, is
now removed. This is because of the behavior of the socket option
SO_REUSEADDR in UDP.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-09-08 18:58:43 +02:00
Mariusz Felisiak 11749e2dc2
bpo-44740: Lowercase "internet" and "web" where appropriate. (#27378)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-07-27 00:11:55 +02:00
Illia Volochii ddd5f36971
bpo-43234: Prohibit non-ThreadPoolExecutor in loop.set_default_executor (GH-24540) 2021-07-01 17:46:49 +03:00
Pablo Galindo 7719953b30
bpo-44011: Revert "New asyncio ssl implementation (GH-17975)" (GH-25848)
This reverts commit 5fb06edbbb and all
subsequent dependent commits.
2021-05-03 16:21:59 +01:00
Andrew Svetlov 5fb06edbbb
bpo-44011: New asyncio ssl implementation (#17975) 2021-05-03 00:34:15 +03:00
Yurii Karabas e4fe303b8c
bpo-42392: Remove loop parameter from asyncio.tasks and asyncio.subprocess (GH-23521) 2020-11-28 10:21:17 +02:00
Alex Grönholm e3ef4d7f65
bpo-41332: Added missing connect_accepted_socket() to AbstractEventLoop (GH-21533)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Co-authored-by: Kyle Stanley <aeros167@gmail.com>
2020-11-26 12:09:12 +02:00
Markus Mohrhard 374d998b50
bpo-39609: set the thread_name_prefix for the default asyncio executor (GH-18458)
Just a small debugging improvement to identify the asyncio executor threads.
2020-02-27 12:01:47 -08:00
Andrew Svetlov 10ac0cded2 bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863)
https://bugs.python.org/issue39191
2020-01-07 05:23:01 -08:00
Andrew Svetlov 3a5de51159
Fix #39191: Don't spawn a task before failing (#17796) 2020-01-04 11:10:14 +02:00
Kyle Stanley ab513a38c9 bpo-37228: Fix loop.create_datagram_endpoint()'s usage of SO_REUSEADDR (#17311) 2019-12-09 15:21:10 +01:00
Kyle Stanley 9fdc64cf12 bpo-34037: Fix test_asyncio failure and add loop.shutdown_default_executor() (GH-15735) 2019-09-19 15:47:22 +03:00
Andrew Svetlov 0237265e82
Use threadpool for reading from file in sendfile fallback mode (#14076) 2019-06-15 14:05:35 +03:00
Andrew Svetlov ef2152354f
bpo-37279: Fix asyncio sendfile support when extra data are sent in fallback mode. (GH-14075) 2019-06-15 14:05:08 +03:00
Łukasz Langa 7f9a2ae780
Revert "bpo-34037, asyncio: add BaseEventLoop.wait_executor_on_close (GH-13786)" (#13802)
This reverts commit 0f0a30f4da.
2019-06-04 13:03:20 +02:00
Victor Stinner 0f0a30f4da
bpo-34037, asyncio: add BaseEventLoop.wait_executor_on_close (GH-13786)
Add BaseEventLoop.wait_executor_on_close attribute: true by default.

loop.close() now waits for the default executor to finish by default.
Set loop.wait_executor_on_close attribute to False to not wait for
the executor.
2019-06-03 23:31:04 +02:00
依云 744c08a9c7 bpo-35246: fix support for path-like args in asyncio subprocess (GH-13628)
Drop isinstance checks from create_subprocess_exec function and let
subprocess module do them.

https://bugs.python.org/issue35246


https://bugs.python.org/issue35246
2019-05-28 23:50:59 -07:00
sbstp f0d4c64019 bpo-36686: Improve the documentation of the std* params in loop.subprocess_exec (GH-13586)
https://bugs.python.org/issue36686
2019-05-27 16:51:19 -07:00
Yury Selivanov 8cd5165ba0 bpo-37027: Return a proxy socket object from transp.get_extra_info('socket') (GH-13530)
Return a safe to use proxy socket object from `transport.get_extra_info('socket')`




https://bugs.python.org/issue37027
2019-05-27 06:57:19 -07:00
Andrew Svetlov 1f39c28e48 bpo-37035: Don't log OSError (GH-13548)
https://bugs.python.org/issue37035
2019-05-27 06:28:34 -07:00