summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
Commit message (Collapse)AuthorAgeFilesLines
* [3.7] bpo-39191: Don't spawn a task before failing (GH-17796) (#17821)Andrew Svetlov2020-01-041-3/+7
| | | | | (cherry picked from commit 3a5de511596f17575de082dcb8d43d63b2bd2da9) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-37228: Fix loop.create_datagram_endpoint()'s usage of SO_REUSEADDR ↵Ned Deily2019-12-111-7/+18
| | | | | | | (GH-17311) (GH-17570) (cherry picked from commit ab513a38c98695f271e448fe2cb7c5e39eeaaaaf) Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* bpo-39006: Fix asyncio when the ssl module is missing (GH-17524)Miss Islington (bot)2019-12-091-10/+10
| | | | | | | Fix asyncio when the ssl module is missing: only check for ssl.SSLSocket instance if the ssl module is available. (cherry picked from commit 82b4950b5e92bec343a436b3f9c116400b66e1b9) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-37404: Raising value error if an SSLSocket is passed to asyncio ↵Miss Islington (bot)2019-12-071-0/+10
| | | | | | | | functions (GH-16457) https://bugs.python.org/issue37404 (cherry picked from commit 892f9e0777f262d366d4747a54c33a1c15a49da6) Co-authored-by: idomic <michael.ido@gmail.com>
* bpo-38785: Prevent asyncio from crashing (GH-17144)Miss Islington (bot)2019-11-131-1/+4
| | | | | | | | if parent `__init__` is not called from a constructor of object derived from `asyncio.Future` https://bugs.python.org/issue38785 (cherry picked from commit dad6be5ffe48beb74fad78cf758b886afddc7aed) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-34344 Fix AbstractEventLoopPolicy.get_event_loop docstring (GH-16463)Miss Islington (bot)2019-10-031-2/+2
| | | | | (cherry picked from commit b23a8423a923077e4f83d3f328bb7542b4c940ed) Co-authored-by: idomic <michael.ido@gmail.com>
* Fix and improve `asyncio.run()` docs (GH-16403) (GH-16505)Miss Islington (bot)2019-10-011-5/+1
| | | | | (cherry picked from commit e407013089259e4c0b271703e1975bbcd578a2d5) Co-authored-by: Kyle Stanley <aeros167@gmail.com>
* bpo-38019: correctly handle pause/resume reading of closed asyncio unix pipe ↵Miss Islington (bot)2019-09-291-0/+11
| | | | | | | (GH-16472) (cherry picked from commit 58498bc7178608b1ab031994ca09c43889ce3e76) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-38260: Add Docs on asyncio.run (GH-16337)Miss Islington (bot)2019-09-251-0/+4
| | | | | | | | | | Add docs about return and raise exception on asyncio.run https://bugs.python.org/issue38260 Automerge-Triggered-By: @asvetlov (cherry picked from commit 17deb16883fa574a86e42551cc37f044182347ad) Co-authored-by: Emmanuel Arias <emmanuelarias30@gmail.com>
* [3.7] bpo-37279: Fix asyncio sendfile support when extra data are sent in ↵Andrew Svetlov2019-06-151-2/+2
| | | | | | | fallback mode. (GH-14075). (GH-14103) (cherry picked from commit ef2152354f03a165c5e3adb53e2276934fabd50a) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* Use threadpool for reading from file in sendfile fallback mode (GH-14076)Miss Islington (bot)2019-06-151-1/+1
| | | | | (cherry picked from commit 0237265e8287141c40faa8719da3a2d21d511d0d) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-36607: Eliminate RuntimeError raised by asyncio.all_tasks() (GH-13971)Miss Islington (bot)2019-06-111-6/+32
| | | | | | | | If internal tasks weak set is changed by another thread during iteration. https://bugs.python.org/issue36607 (cherry picked from commit 65aa64fae89a24491aae84ba0329eb8f3c68c389) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* [3.7] bpo-37035: Don't log OSError (GH-13548) (#13594)Andrew Svetlov2019-05-275-9/+4
| | | | | | https://bugs.python.org/issue37035. (cherry picked from commit 1f39c28e489cca0397fc4c3675d13569318122ac) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-35721: Close socket pair if Popen in _UnixSubprocessTransport fails ↵Miss Islington (bot)2019-05-201-6/+12
| | | | | | | | | | (GH-11553) This slightly expands an existing test case `test_popen_error` to trigger a `ResourceWarning` and fixes it. https://bugs.python.org/issue35721 (cherry picked from commit 9932fd91e878b740704ff599522e945a4bbe2ae1) Co-authored-by: Niklas Fiekas <niklas.fiekas@backscattering.de>
* bpo-35545: Fix asyncio discarding IPv6 scopes (GH-11271)Miss Islington (bot)2019-05-171-3/+3
| | | | | | | | | | 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 (cherry picked from commit ac8eb8f36bf7ca636f8d886eb65a3b532f4725d5) Co-authored-by: Erwan Le Pape <lepaperwan@users.noreply.github.com>
* Revert "bpo-36801: Fix waiting in StreamWriter.drain for closing SSL ↵Victor Stinner2019-05-142-22/+8
| | | | | transport (GH-13098)" (GH-13328) This reverts commit 93aa57ac6594d1cc30d147720fc8a7a4e1ca2d3e.
* bpo-36801: Fix waiting in StreamWriter.drain for closing SSL transport ↵Miss Islington (bot)2019-05-072-8/+22
| | | | | | | | (GH-13098) https://bugs.python.org/issue36801 (cherry picked from commit 1cc0ee7d9f6a2817918fafd24c18d8bb093a85d3) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-35125: remove inner callback on outer cancellation in asyncio shield ↵Miss Islington (bot)2019-05-071-2/+8
| | | | | | | | | | | | | | | (GH-10340) When the future returned by shield is cancelled, its completion callback of the inner future is not removed. This makes the callback list of inner inner future grow each time a shield is created and cancelled. This change unregisters the callback from the inner future when the outer future is cancelled. https://bugs.python.org/issue35125 (cherry picked from commit b35acc5b3a0148c5fd4462968b310fb436726d5a) Co-authored-by: Romain Picard <romain.picard@oakbits.com>
* bpo-31922: Do not connect UDP sockets when broadcast is allowed (GH-423)Miss Islington (bot)2019-05-072-7/+13
| | | | | | | | | | | | | | *Moved from python/asyncioGH-493.* This PR fixes issue python/asyncioGH-480, as explained in [this comment](https://github.com/python/asyncio/issues/480GH-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 (cherry picked from commit 63deaa5b70108ef441c57728322da6b4321db4fc) Co-authored-by: Vincent Michel <vxgmichel@gmail.com>
* bpo-36613: call remove_done_callback if exception (GH-12800)Miss Islington (bot)2019-05-031-1/+2
| | | | | | | | Call remove_done_callback() in finally block. https://bugs.python.org/issue36613 (cherry picked from commit c1964e9e2177eabe821f3e4243be8b99e0d2d542) Co-authored-by: gescheit <gescheit12@gmail.com>
* bpo-34745: Fix asyncio sslproto memory issues (GH-12386)Miss Islington (bot)2019-03-171-0/+4
| | | | | | | | | | | | | | | | * Fix handshake timeout leak in asyncio/sslproto Refs MagicStack/uvloopGH-222 * Break circular ref _SSLPipe <-> SSLProtocol * bpo-34745: Fix asyncio ssl memory leak * Break circular ref SSLProtocol <-> UserProtocol * Add NEWS entry (cherry picked from commit f683f464259715d620777d7ed568e701337a703a) Co-authored-by: Fantix King <fantix.king@gmail.com>
* bpo-23846: Fix ProactorEventLoop._write_to_self() (GH-11566)Miss Islington (bot)2019-01-151-1/+7
| | | | | | | | | asyncio.ProactorEventLoop now catchs and logs send errors when the self-pipe is full: BaseProactorEventLoop._write_to_self() now catchs and logs OSError exceptions, as done by BaseSelectorEventLoop._write_to_self(). (cherry picked from commit c9f872b0bdce5888f1879fa74e098bf4a05430c5) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* [3.7] bpo-34323: Enhance IocpProactor.close() log (GH-11565)Victor Stinner2019-01-151-8/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | * IocpProactor: prevent modification if closed (GH-11494) * _wait_for_handle(), _register() and _unregister() methods of IocpProactor now raise an exception if closed * Add "closed" to IocpProactor.__repr__() * Simplify IocpProactor.close() (cherry picked from commit 9b07681c09182d4b9d23cd52566a4992b8afecbb) * bpo-34323: Enhance IocpProactor.close() log (GH-11555) IocpProactor.close() now uses time to decide when to log: wait 1 second before the first log, then log every second. Log also the number of seconds since close() was called. (cherry picked from commit b1e45739d832e1e402a563c6727defda92e193b7) * bpo-34323: Enhance IocpProactor.close() log again (GH-11563) Add repr(self) to the log to display the number of pending overlapped in the log. (cherry picked from commit b91140fdb17472d03a7b7971f143c08a40fde923)
* bpo-35682: Fix _ProactorBasePipeTransport._force_close() (GH-11462)Miss Islington (bot)2019-01-081-1/+1
| | | | | | | | | | bpo-32622, bpo-35682: Fix asyncio.ProactorEventLoop.sendfile(): don't attempt to set the result of an internal future if it's already done. Fix asyncio _ProactorBasePipeTransport._force_close(): don't set the result of _empty_waiter if it's already done. (cherry picked from commit 80fda712c83f5dd9560d42bf2aa65a72b18b7759) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* [3.7] bpo-35380: Enable TCP_NODELAY for proactor event loop (GH-10867) ↵Miss Islington (bot)2018-12-033-12/+17
| | | | | | | | | (GH-10872) * bpo-35380: Enable TCP_NODELAY for proactor event loop (GH-10867) (cherry picked from commit 3bc0ebab17bf5a2c29d2214743c82034f82e6573) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-34970: Protect tasks weak set manipulation in asyncio.all_tasks() ↵Miss Islington (bot)2018-10-131-2/+6
| | | | | | | | (GH-9837) (GH-9849) https://bugs.python.org/issue34970 (cherry picked from commit 97cf0828727ac2a269c89c5aa09570a69a22c83c) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-34769: Thread safety for _asyncgen_finalizer_hook(). (GH-9716)Miss Islington (bot)2018-10-091-4/+1
| | | | | (cherry picked from commit c880ffe7d2ce2fedb1831918c8a36e3623e0fb76) Co-authored-by: twisteroid ambassador <twisteroidambassador@users.noreply.github.com>
* [3.7] bpo-34263 Cap timeout submitted to epoll/select etc. to one day. ↵Miss Islington (bot)2018-07-311-1/+4
| | | | (GH-8532) (GH-8586)
* bpo-33833: Fix ProactorSocketTransport AssertionError (GH-7893)Miss Islington (bot)2018-07-301-0/+4
| | | | | (cherry picked from commit 9045199c5aaeac9b52537581be127d999b5944ee) Co-authored-by: twisteroid ambassador <twisteroidambassador@users.noreply.github.com>
* bpo-27500: Fix static version of getaddrinfo to resolve IPv6 (GH-7993)Miss Islington (bot)2018-06-291-4/+10
| | | | | (cherry picked from commit d904c238ca3551750cb97d15d827c3e525970867) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-30805: Avoid race condition with debug logging (GH-7545)Miss Islington (bot)2018-06-081-2/+4
| | | | | | Supersedes https://github.com/python/cpython/pull/2490 (cherry picked from commit 12f482e0ae33021c04264294f33fa6baa9617cec) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33694: Fix typo in helper function name (GH-7522)Miss Islington (bot)2018-06-083-3/+3
| | | | | | | | | _feed_data_to_bufferred_proto() renamed to _feed_data_to_buffered_proto() ("bufferred" => "buffered"). Typo spotted by Nathaniel J. Smith. (cherry picked from commit ff6c07729211fb98431a2793e074d07a21e0650a) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33792: Add selector and proactor windows policies (GH-7487)Miss Islington (bot)2018-06-081-3/+8
| | | | | (cherry picked from commit 8f4042964d5b0ddf5cdf87862db962ba64e3f64a) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33694: Fix race condition in asyncio proactor (GH-7498) (GH-7499)Miss Islington (bot)2018-06-073-145/+73
| | | | | | | | | | | | | | | | | | | The cancellation of an overlapped WSARecv() has a race condition which causes data loss because of the current implementation of proactor in asyncio. No longer cancel overlapped WSARecv() in _ProactorReadPipeTransport to work around the race condition. Remove the optimized recv_into() implementation to get simple implementation of pause_reading() using the single _pending_data attribute. Move _feed_data_to_bufferred_proto() to protocols.py. Remove set_protocol() method which became useless. (cherry picked from commit 79790bc35fe722a49977b52647f9b5fe1deda2b7) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33769: start_tls: Fix error message; cancel callbacks on error (GH-7403) ↵Miss Islington (bot)2018-06-052-3/+6
| | | | | | | | (GH-7428) In addition to that, mark SSLTransport as "closed" in its "abort()" method to prevent bogus warnings. (cherry picked from commit 415bc46a78e785f357c8960ae70f18a6b6cccbb6) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33734: asyncio/ssl: a bunch of bugfixes (GH-7321) (GH-7396)Miss Islington (bot)2018-06-044-37/+39
| | | | | | | | | | * 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) (cherry picked from commit 9602643120a509858d0bee4215d7f150e6125468) Co-authored-by: Yury Selivanov <yury@magic.io>
* Revert "bpo-22087: Fix Policy.get_event_loop() to detect fork (GH-7208)" ↵Yury Selivanov2018-05-301-7/+0
| | | | | (GH-7233) This reverts commit 2a7eb0b531656f4a77d85078e6e009e4b3639ef9.
* bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216)Miss Islington (bot)2018-05-291-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, asyncio.wait_for(fut), upon reaching the timeout deadline, cancels the future and returns immediately. This is problematic for when *fut* is a Task, because it will be left running for an arbitrary amount of time. This behavior is iself surprising and may lead to related bugs such as the one described in bpo-33638: condition = asyncio.Condition() async with condition: await asyncio.wait_for(condition.wait(), timeout=0.5) Currently, instead of raising a TimeoutError, the above code will fail with `RuntimeError: cannot wait on un-acquired lock`, because `__aexit__` is reached _before_ `condition.wait()` finishes its cancellation and re-acquires the condition lock. To resolve this, make `wait_for` await for the task cancellation. The tradeoff here is that the `timeout` promise may be broken if the task decides to handle its cancellation in a slow way. This represents a behavior change and should probably not be back-patched to 3.6 and earlier. (cherry picked from commit e2b340ab4196e1beb902327f503574b5d7369185) Co-authored-by: Elvis Pranskevichus <elvis@magic.io>
* bpo-32684: Fix gather to propagate cancel of itself with return_exceptions ↵Miss Islington (bot)2018-05-291-1/+13
| | | | | | | (GH-7209) (#7222) (cherry picked from commit 863b6749093a86810c4077112a857363410cc221) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-22087: Fix Policy.get_event_loop() to detect fork (GH-7208)Miss Islington (bot)2018-05-291-0/+7
| | | | | | Original patch by Dan O'Reilly. (cherry picked from commit 5d97b7bcc19496617bf8c448d2f149cc28c73bc7) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33353: test_asyncio use set_write_buffer_limits() (GH-7200)Miss Islington (bot)2018-05-291-1/+1
| | | | | | | | | | Use transport.set_write_buffer_limits() in sendfile tests of test_asyncio to make sure that the protocol is paused after sending 4 KiB. Previously, test_sendfile_fallback_close_peer_in_the_middle_of_receiving() failed on FreeBSD if the DATA was smaller than the default limit of 64 KiB. (cherry picked from commit 9551f7719213243fd96c4f284079243773c26b3c) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33654: Support protocol type switching in SSLTransport.set_protocol() ↵Miss Islington (bot)2018-05-291-4/+7
| | | | | | | (GH-7194) (cherry picked from commit 2179022d94937d7b0600b0dc192ca6fa5f53d830) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33674: Pause the transport as early as possible (GH-7192)Miss Islington (bot)2018-05-291-2/+5
| | | | | (cherry picked from commit f295587c45f96b62d24f9a12cef6931b0805f596) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33674: asyncio: Fix SSLProtocol race (GH-7175) (#7187)Miss Islington (bot)2018-05-291-1/+1
| | | | | | | | | Fix a race condition in SSLProtocol.connection_made() of asyncio.sslproto: start immediately the handshake instead of using call_soon(). Previously, data_received() could be called before the handshake started, causing the handshake to hang or fail. (cherry picked from commit be00a5583a2cb696335c527b921d1868266a42c6) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-32410: Avoid blocking on file IO in sendfile fallback code (GH-7172) (#7182)Miss Islington (bot)2018-05-292-2/+9
| | | | | (cherry picked from commit 7165754b6b5f3b7c07050d921fa1c58bba5f0ff1) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-32610: Fix asyncio.all_tasks() to return only pending tasks. (GH-7174)Miss Islington (bot)2018-05-293-3/+16
| | | | | (cherry picked from commit 416c1ebd9896b394790dcb4f9f035b1a44ebe9ff) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33469: RuntimeError after closing loop that used run_in_executor (GH-7171)Miss Islington (bot)2018-05-281-0/+3
| | | | | (cherry picked from commit fdccfe09f0b10776645fdb04a0783d6864c32b21) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33672: Fix Task.__repr__ crash with Cython's bogus coroutines (GH-7161) ↵Miss Islington (bot)2018-05-282-40/+50
| | | | | | | (GH-7173) (cherry picked from commit 989b9e0e6d7dd2fa911f9bfd4744e7f3a82d6006) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33654: Support BufferedProtocol in set_protocol() and start_tls() (GH-7130)Miss Islington (bot)2018-05-286-26/+107
| | | | | | | | | | | | | 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 (cherry picked from commit dbf102271fcc316f353c7e0a283811b661d128f2) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-33505: Optimize asyncio.ensure_future by reordering if conditions ↵Miss Islington (bot)2018-05-281-5/+5
| | | | | | | (GH-6836) (#7162) (cherry picked from commit e549c4be5fb010f5faf12236af8faa720a1429be) Co-authored-by: jimmylai <albert_chs@yahoo.com.tw>