Commit Graph

242 Commits

Author SHA1 Message Date
Erwan Le Pape ac8eb8f36b bpo-35545: Fix asyncio discarding IPv6 scopes (GH-11271)
This PR proposes a solution to [bpo-35545](https://bugs.python.org/issue35545) by adding an optional `flowinfo` and `scopeid` to `asyncio.base_events._ipaddr_info` to carry the full address information into `_ipaddr_info` and avoid discarding IPv6 specific information.

Changelog entry & regression tests to come.


https://bugs.python.org/issue35545
2019-05-17 01:28:39 -07:00
Vincent Michel 63deaa5b70 bpo-31922: Do not connect UDP sockets when broadcast is allowed (GH-423)
*Moved from python/asyncio#493.*

This PR fixes issue python/asyncio#480, as explained in [this comment](https://github.com/python/asyncio/issues/480#issuecomment-278703828).

The `_SelectorDatagramTransport.sendto` method has to be modified ~~so `_sock.sendto` is used in all cases (because it is tricky to reliably tell if the socket is connected or not). Could that be an issue for connected sockets?~~ *EDIT* ... so `_sock.send` is used only if `_sock` is connected.

It also protects `socket.getsockname` against `OSError` in `_SelectorTransport`. This might happen on Windows if the socket is not connected (e.g. for UDP broadcasting).


https://bugs.python.org/issue31922
2019-05-07 10:18:49 -07:00
twisteroid ambassador 88f07a804a bpo-33530: Implement Happy Eyeballs in asyncio, v2 (GH-7237)
Added two keyword arguments, `delay` and `interleave`, to
`BaseEventLoop.create_connection`. Happy eyeballs is activated if
`delay` is specified.

We now have documentation for the new arguments. `staggered_race()` is in its own module, but not exported to the main asyncio package.


https://bugs.python.org/issue33530
2019-05-05 04:14:35 -07:00
Quentin Dawans 56065d4c8a bpo-34139: Remove unix datagram socket from FS before binding (GH-8323)
https://bugs.python.org/issue34139
2019-04-09 06:40:59 -07:00
Inada Naoki f345170940
asyncio: use dict instead of OrderedDict (GH-11710) 2019-02-05 17:04:40 +09:00
Victor Stinner fb2c3465f0
asyncio: __del__() keep reference to warnings.warn (GH-11491)
* asyncio: __del__() keep reference to warnings.warn

The __del__() methods of asyncio classes now keep a strong reference
to the warnings.warn() to be able to display the ResourceWarning
warning in more cases. Ensure that the function remains available if
instances are destroyed late during Python shutdown (while module
symbols are cleared).

* Rename warn parameter to _warn

"_warn" name is a hint that it's not the regular warnings.warn()
function.
2019-01-10 11:24:40 +01:00
Andrew Svetlov 3bc0ebab17
bpo-35380: Enable TCP_NODELAY for proactor event loop (#10867) 2018-12-03 21:08:13 +02:00
Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి) 70f61b933f bpo-35202: Remove unused imports in Lib directory (GH-10450) 2018-11-15 21:59:19 +09:00
twisteroid ambassador c880ffe7d2 bpo-34769: Thread safety for _asyncgen_finalizer_hook(). (GH-9716) 2018-10-09 11:30:21 -04:00
Andrew Svetlov d5bd036138 bpo-34849: Don't log wating for selector.select in asyncio loop iteration (GH-9641)
The waiting is pretty normal for any asyncio program, logging its time just adds
a noise to logs without any useful information provided.



https://bugs.python.org/issue34849
2018-09-29 22:28:40 -07:00
Andrew Svetlov 0dd71807a9
bpo-34630: Skip logging SSL certificate errors by asyncio code (GH-9169) 2018-09-12 14:03:54 -07:00
Andrew Svetlov 0baa72f4b2
bpo-34622: Extract asyncio exceptions into a separate module (GH-9141) 2018-09-11 10:13:04 -07:00
Alex Grönholm cca4eec3c0 bpo-34270: Make it possible to name asyncio tasks (GH-8547)
Co-authored-by: Antti Haapala <antti.haapala@anttipatterns.com>
2018-08-08 17:06:47 -04:00
MartinAltmayer 944451cd8d bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532) 2018-07-31 10:06:12 -04:00
Elvis Pranskevichus 22d25085db bpo-34075: Deprecate non-ThreadPoolExecutor in loop.set_default_executor() (GH-8533)
Various asyncio internals expect that the default executor is a
`ThreadPoolExecutor`, so deprecate passing anything else to
`loop.set_default_executor()`.
2018-07-30 12:42:43 +02:00
Yury Selivanov d904c238ca
bpo-27500: Fix static version of getaddrinfo to resolve IPv6 (GH-7993) 2018-06-28 21:59:32 -04:00
Yury Selivanov 12f482e0ae
bpo-30805: Avoid race condition with debug logging (GH-7545)
Supersedes https://github.com/python/cpython/pull/2490
2018-06-08 18:24:37 -04:00
Yury Selivanov 415bc46a78
bpo-33769: start_tls: Fix error message; cancel callbacks on error (GH-7403)
In addition to that, mark SSLTransport as "closed" in its "abort()" method to prevent bogus warnings.
2018-06-05 08:59:58 -04:00
Yury Selivanov 9602643120
bpo-33734: asyncio/ssl: a bunch of bugfixes (#7321)
* Fix AttributeError (not all SSL exceptions have 'errno' attribute)

* Increase default handshake timeout from 10 to 60 seconds
* Make sure start_tls can be cancelled correctly
* Make sure any error in SSLProtocol gets propagated (instead of just being logged)
2018-06-04 11:32:35 -04:00
Yury Selivanov f295587c45
bpo-33674: Pause the transport as early as possible (#7192) 2018-05-29 01:00:12 -04:00
Yury Selivanov 7165754b6b
bpo-32410: Avoid blocking on file IO in sendfile fallback code (GH-7172) 2018-05-28 18:31:55 -04:00
Yury Selivanov dbf102271f
bpo-33654: Support BufferedProtocol in set_protocol() and start_tls() (GH-7130)
In this commit:

* Support BufferedProtocol in set_protocol() and start_tls()
* Fix proactor to cancel readers reliably
* Update tests to be compatible with OpenSSL 1.1.1
* Clarify BufferedProtocol docs
* Bump TLS tests timeouts to 60 seconds; eliminate possible race from start_serving
* Rewrite test_start_tls_server_1
2018-05-28 14:31:28 -04:00
Yury Selivanov bec2372b7e
bpo-32327: Revert loop.run_in_executor behaviour: return a Future. (#5392)
I've run some tests on 3.7 asyncio and it appears that too many
things assume that run_in_executor returns a Future.
2018-01-28 14:09:40 -05:00
Yury Selivanov b1a6ac4c40
bpo-32622: Enforce sendfile fallback policy for FALLBACK transports (#5364) 2018-01-27 15:52:52 -05:00
Andrew Svetlov 7c684073f9
bpo-32622: Implement loop.sendfile() (#5271) 2018-01-27 21:22:47 +02:00
Yury Selivanov c9070d03f5
bpo-32662: Implement Server.start_serving() and Server.serve_forever() (#5312)
* bpo-32662: Implement Server.start_serving() and Server.serve_forever()

New methods:

* Server.start_serving(),
* Server.serve_forever(), and
* Server.is_serving().

Add 'start_serving' keyword parameter to loop.create_server() and
loop.create_unix_server().
2018-01-25 18:08:09 -05:00
Yury Selivanov f23746a934
bpo-32436: Implement PEP 567 (#5027) 2018-01-22 19:11:18 -05:00
Yury Selivanov a4afcdfa55
bpo-32314: Fix asyncio.run() to cancel runinng tasks on shutdown (#5262) 2018-01-21 14:56:59 -05:00
Nathaniel J. Smith fc2f407829 bpo-32591: Add native coroutine origin tracking (#5250)
* Add coro.cr_origin and sys.set_coroutine_origin_tracking_depth
* Use coroutine origin information in the unawaited coroutine warning
* Stop using set_coroutine_wrapper in asyncio debug mode
* In BaseEventLoop.set_debug, enable debugging in the correct thread
2018-01-21 09:44:07 -05:00
Andrew Svetlov 7464e87a65
bpo-32410: Make SendfileNotAvailableError exception public (#5243) 2018-01-19 20:04:29 +02:00
Andrew Svetlov 6b5a27975a
bpo-32410: Implement loop.sock_sendfile() (#4976) 2018-01-16 19:59:34 +02:00
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) 1634fc289a bpo-32418: Add get_loop() method on Server, AbstractServer classes (#4997)
* Add abstract get_loop() method to Server, AbstractServer classes.
* Add test cases for get_loop() method in Server, AbstractServer classes
* Add documentation for get_loop() method
2017-12-30 17:09:32 +02:00
Yury Selivanov f111b3dcb4
bpo-23749: Implement loop.start_tls() (#5039) 2017-12-30 00:35:36 -05:00
Yury Selivanov ca9b36cd1a
bpo-32415: Add asyncio.Task.get_loop() and Future.get_loop() (#4992) 2017-12-23 15:04:15 -05:00
Andrew Svetlov 51eb1c6b9c
bpo-29970: Make ssh_handshake_timeout None by default (#4939)
* Make ssh_handshake_timeout None by default.
* Raise ValueError if ssl_handshake_timeout is used without ssl.
* Raise ValueError if ssl_handshake_timeout is not positive.
2017-12-20 20:24:43 +02:00
Neil Aspinall f7686c1f55 bpo-29970: Add timeout for SSL handshake in asyncio
10 seconds by default.
2017-12-19 21:45:42 +02:00
Yury Selivanov 36c2c04478
bpo-32355: Optimize asyncio.gather() (#4913) 2017-12-19 07:19:53 -05:00
Yury Selivanov a7bd64c0c0
bpo-27456: Simplify sock type checks (#4922)
Recent sock.type fix (see bug 32331) makes sock.type checks simpler
in asyncio.
2017-12-19 06:44:37 -05:00
Yury Selivanov e796b2fe26
bpo-27456: Ensure TCP_NODELAY is set on linux (#4231) 2017-12-15 19:32:25 -05:00
Yury Selivanov 19a44f63c7
bpo-32327: Convert asyncio functions documented as coroutines to coroutines. (#4872) 2017-12-14 20:53:26 -05:00
Yury Selivanov 19d0d54809
bpo-32262: Fix f-string (#4787) 2017-12-10 19:52:53 -05:00
Yury Selivanov 6370f345e1
bpo-32262: Fix codestyle; use f-strings formatting where necessary. (#4775) 2017-12-10 18:36:12 -05:00
Andrew Svetlov 5f841b5538
bpo-32193: Convert asyncio to async/await usage (#4753)
* Convert asyncio/tasks.py to async/await

* Convert asyncio/queues.py to async/await

* Convert asyncio/test_utils.py to async/await

* Convert asyncio/base_subprocess.py to async/await

* Convert asyncio/subprocess.py to async/await

* Convert asyncio/streams.py to async/await

* Fix comments

* Convert asyncio/locks.py to async/await

* Convert asyncio.sleep to async def

* Add a comment

* Add missing news

* Convert stubs from AbstrctEventLoop to async functions

* Convert subprocess_shell/subprocess_exec

* Convert connect_read_pipe/connect_write_pip to async/await syntax

* Convert create_datagram_endpoint

* Convert create_unix_server/create_unix_connection

* Get rid of old style coroutines in unix_events.py

* Convert selector_events.py to async/await

* Convert wait_closed and create_connection

* Drop redundant line

* Convert base_events.py

* Code cleanup

* Drop redundant comments

* Fix indentation

* Add explicit tests for compatibility between old and new coroutines

* Convert windows event loop to use async/await

* Fix double awaiting of async function

* Convert asyncio/locks.py

* Improve docstring

* Convert tests to async/await

* Convert more tests

* Convert more tests

* Convert more tests

* Convert tests

* Improve test
2017-12-09 00:23:48 +02:00
Victor Stinner 28e61650b2
bpo-31245: asyncio: Fix typo, isistance => isinstance (#4594) 2017-11-28 00:34:08 +01:00
Victor Stinner 44862df2ee
bpo-32047: -X dev enables asyncio debug mode (#4418)
The new -X dev command line option now also enables asyncio debug
mode.
2017-11-20 07:14:07 -08:00
Antoine Pitrou 921e9432a1
bpo-31970: Reduce performance overhead of asyncio debug mode. (#4314)
* bpo-31970: Reduce performance overhead of asyncio debug mode.
2017-11-07 17:23:29 +01:00
Quentin Dawans fe4ea9cf1e bpo-31245: Asyncio unix socket datagram (#3164) 2017-10-30 09:43:02 -04:00
jimmylai 21b3e04c13 call remove_done_callback in finally section (#1688) 2017-05-22 22:32:46 -07:00
INADA Naoki 3e2ad8ec61 bpo-29617: Remove Python 3.3 support from asyncio (GH-232) 2017-04-25 10:57:18 +09:00
Serhiy Storchaka 2e576f5aec bpo-30144: Import collections ABC from collections.abc rather than collections. (#1263) 2017-04-24 09:05:00 +03:00
Serhiy Storchaka 5affd23e6f bpo-29762: More use "raise from None". (#569)
This hides unwanted implementation details from tracebacks.
2017-04-05 09:37:24 +03:00
Serhiy Storchaka 70d28a184c Remove unused imports. 2016-12-16 20:00:15 +02:00
Yury Selivanov 5cb0c09fa6 Merge 3.5 (issue #28652) 2016-11-21 17:47:41 -05:00
Yury Selivanov dab0584738 Issue #28652: Partially rollback previous changes
Allow AF_UNIX in create_server & create_connection
2016-11-21 17:47:27 -05:00
Yury Selivanov 954c7dd0cc Merge 3.5 (issue #28652) 2016-11-09 15:47:47 -05:00
Yury Selivanov a1a8b7d3d7 Issue #28652: Make loop methods reject socket kinds they do not support. 2016-11-09 15:47:00 -05:00
Yury Selivanov 69312fa4a2 Merge 3.5 (issue #28613) 2016-11-04 14:30:11 -04:00
Yury Selivanov 600a349781 Issue #28613: Fix get_event_loop() to return the current loop
when called from coroutines or callbacks.
2016-11-04 14:29:28 -04:00
Yury Selivanov c5420492cf asyncio: Sync with upstream 2016-11-03 15:35:23 -07:00
Yury Selivanov a6fbcd19ac Merge 3.5 (issue #28600) 2016-11-03 15:10:11 -07:00
Yury Selivanov 491a912659 Issue #28600: Optimize loop.call_soon().
Run expensive type checks only in debug mode.  In addition, stop
supporting passing handles to loop.run_in_executor.
2016-11-03 15:09:24 -07:00
Yury Selivanov a0c1ba608e Issue #28544: Implement asyncio.Task in C.
This implementation provides additional 10-20% speed boost for
asyncio programs.

The patch also fixes _asynciomodule.c to use Arguments Clinic, and
makes '_schedule_callbacks' an overridable method (as it was in 3.5).
2016-10-28 12:52:37 -04:00
Yury Selivanov 6330f2a5ce Merge 3.5 (issue #26796) 2016-10-21 17:41:23 -04:00
Yury Selivanov e8a6045fea Issue #26796: Don't configure the number of workers for default threadpool executor.
Initial patch by Hans Lawrenz.
2016-10-21 17:40:42 -04:00
Yury Selivanov ed0540698e Issue #28500: Fix asyncio to handle async gens GC from another thread. 2016-10-21 17:13:40 -04:00
Yury Selivanov d2c5fab7c6 Merge 3.5 (issue #28371) 2016-10-05 18:29:04 -04:00
Yury Selivanov 0de3de6cbf Issue #28371: Deprecate passing asyncio.Handles to run_in_executor. 2016-10-05 18:28:09 -04:00
Guido van Rossum 0035be3fee Misc asyncio improvements from upstream (merge 3.5->3.6) 2016-09-30 08:18:34 -07:00
Guido van Rossum e3c65a7a22 Misc asyncio improvements from upstream 2016-09-30 08:17:15 -07:00
Yury Selivanov 1b984ffd44 Merge 3.5 (issue #28174) 2016-09-15 15:46:16 -04:00
Yury Selivanov 5587d7c071 Issue #28174: Handle when SO_REUSEPORT isn't properly supported (asyncio)
Patch by Seth Michael Larson.
2016-09-15 15:45:07 -04:00
Yury Selivanov d070154fb5 Merge 3.5 (issue #27906) 2016-09-15 14:14:48 -04:00
Yury Selivanov a1b0e7db73 Issue #27906: Fix socket accept exhaustion during high TCP traffic.
Patch by Kevin Conway.
2016-09-15 14:13:15 -04:00
Yury Selivanov 4357cf6202 Another asyncio sync. 2016-09-15 13:49:08 -04:00
Yury Selivanov 0a91d484a3 Merge 3.5 (asyncio) 2016-09-15 13:24:03 -04:00
Yury Selivanov f6d991d885 asyncio: Sync with the upstream 2016-09-15 13:10:51 -04:00
Raymond Hettinger f1024f7425 merge 2016-09-09 15:58:00 -07:00
Guido van Rossum 7b3b3dc85d Merge asyncio upstream. 2016-09-09 14:26:31 -07:00
Yury Selivanov eb6364557f Issue #28003: Implement PEP 525 -- Asynchronous Generators. 2016-09-08 22:01:51 -07:00
Vinay Sajip dd917f84e3 Closes #27904: Improved logging statements to defer formatting until needed. 2016-08-31 08:22:29 +01:00
Yury Selivanov e824315e2b Merge 3.5 (issue #27392) 2016-07-12 18:24:25 -04:00
Yury Selivanov 252e9ed974 Issue #27392: Add loop.connect_accepted_socket().
Patch by Jim Fulton.
2016-07-12 18:23:10 -04:00
Yury Selivanov 552bf94648 Merge 3.5 (issue #27136, asyncio) 2016-06-08 12:33:59 -04:00
Yury Selivanov f1c6fa9866 Issue #27136: Fix DNS static resolution; don't use it in getaddrinfo
Patch by A. Jesse Jiryu Davis
2016-06-08 12:33:31 -04:00
Yury Selivanov 1f56e5f6af Merge 3.5 (asyncio) 2016-06-02 16:51:27 -04:00
Yury Selivanov a714616d36 asyncio: Fix getaddrinfo to accept service names (for port)
Patch by A. Jesse Jiryu Davis
2016-06-02 16:51:07 -04:00
Yury Selivanov 642afb3d3d Merge 3.5 (asyncio) 2016-06-02 16:44:10 -04:00
Yury Selivanov a8f895f051 asyncio: Support host=b'' for getaddrinfo 2016-06-02 16:43:52 -04:00
Yury Selivanov 72005f1744 Merge 3.5 (asyncio) 2016-05-21 16:50:31 -04:00
Yury Selivanov f0200e06f0 asyncio: Fix BytesWarning (use typed=True in lru_cache for _ipaddr_info) 2016-05-21 16:50:16 -04:00
Yury Selivanov 010f361dad Merge 3.5 (asyncio) 2016-05-20 17:44:44 -04:00
Yury Selivanov eaaaee8c56 asyncio: Fix getaddrinfo to accept None/str/bytes for 'port' arg
Patch by A. Jesse Jiryu Davis.
2016-05-20 17:44:19 -04:00
Yury Selivanov 8ace2c66d3 Merge 3.5 (Issue #27041) 2016-05-16 15:39:39 -04:00
Yury Selivanov 7661db6228 Issue #27041: asyncio: Add loop.create_future method 2016-05-16 15:38:39 -04:00
Yury Selivanov 7c3ac2d1f8 Merge 3.5 (issue #27040) 2016-05-16 15:32:26 -04:00
Yury Selivanov 7ed7ce6ee7 Issue #27040: Add loop.get_exception_handler method 2016-05-16 15:20:38 -04:00
Victor Stinner 00f4648a39 Merge 3.5 (asyncio) 2016-04-01 21:43:54 +02:00
Victor Stinner c94a93aecb asyncio: Don't log ConnectionAbortedError
Issue #26509: In fatal error handlers, don't log ConnectionAbortedError which
occur on Windows.
2016-04-01 21:43:39 +02:00
Victor Stinner e19558af1b Add a source parameter to warnings.warn()
Issue #26604:

* Add a new optional source parameter to _warnings.warn() and warnings.warn()
* Modify asyncore, asyncio and _pyio modules to set the source parameter when
  logging a ResourceWarning warning
2016-03-23 00:28:08 +01:00
Yury Selivanov e076ffb068 asyncio: Remove duplicate bind addresses in create_server.
Patch by Sebastien Bourdeauducq (issue #26338)
2016-03-02 11:17:01 -05:00