summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/proactor_events.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-33694: Fix typo in helper function name (GH-7522)Victor Stinner2018-06-081-1/+1
| | | | | | _feed_data_to_bufferred_proto() renamed to _feed_data_to_buffered_proto() ("bufferred" => "buffered"). Typo spotted by Nathaniel J. Smith.
* bpo-33694: Fix race condition in asyncio proactor (GH-7498)Victor Stinner2018-06-071-125/+53
| | | | | | | | | | | | | | | | 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.
* bpo-33654: Support BufferedProtocol in set_protocol() and start_tls() (GH-7130)Yury Selivanov2018-05-281-11/+41
| | | | | | | | | | | 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
* bpo-26819: Prevent proactor double read on resume (#6921)CtrlZvi2018-05-201-1/+7
| | | | | | | | | | The proactor event loop has a race condition when reading with pausing/resuming. `resume_reading()` unconditionally schedules the read function to read from the current future. If `resume_reading()` was called before the previously scheduled done callback fires, this results in two attempts to get the data from the most recent read and an assertion failure. This commit tracks whether or not `resume_reading` needs to reschedule the callback to restart the loop, preventing a second attempt to read the data.
* bpo-32622: Native sendfile on windows (#5565)Andrew Svetlov2018-02-251-1/+69
| | | * Support sendfile on Windows Proactor event loop naively.
* bpo-32251: Implement asyncio.BufferedProtocol. (#4755)Yury Selivanov2018-01-281-20/+117
|
* bpo-32622: Implement loop.sendfile() (#5271)Andrew Svetlov2018-01-271-1/+8
|
* bpo-23749: Implement loop.start_tls() (#5039)Yury Selivanov2017-12-301-0/+2
|
* bpo-29970: Make ssh_handshake_timeout None by default (#4939)Andrew Svetlov2017-12-201-2/+2
| | | | | * 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.
* bpo-29970: Add timeout for SSL handshake in asyncioNeil Aspinall2017-12-191-7/+13
| | | | 10 seconds by default.
* bpo-29711: Fix stop_serving in proactor loop kill all listening servers (#431)Julien Duponchelle2017-12-191-1/+3
|
* bpo-32356: idempotent pause_/resume_reading; new is_reading method. (#4914)Yury Selivanov2017-12-181-8/+7
|
* bpo-32327: Convert asyncio functions documented as coroutines to coroutines. ↵Yury Selivanov2017-12-151-10/+10
| | | | (#4872)
* bpo-32262: Fix codestyle; use f-strings formatting where necessary. (#4775)Yury Selivanov2017-12-101-13/+14
|
* asyncio: use directly socket.socketpair() (#4597)Victor Stinner2017-11-281-4/+1
| | | | | Since Python 3.5, socket.socketpair() is also available on Windows, and so can be used directly, rather than using asyncio.windows_utils.socketpair().
* bpo-32069: Drop legacy SSL transport (#4451)Andrew Svetlov2017-11-181-5/+0
| | | | | | | | | | * Drop legacy SSL transport * Drop unused import * Fix Windows tests * Drop never executed on Python 3.4+ code
* bpo-31819: Add AbstractEventLoop.sock_recv_into() (#4051)Antoine Pitrou2017-10-191-0/+3
| | | | | | | | * bpo-31819: Add AbstractEventLoop.sock_recv_into() * Add NEWS * Add doc
* Fix TypeError is asyncio/proactor_events (#993)Jim Fasarakis-Hilliard2017-06-101-2/+3
|
* bpo-29617: Remove Python 3.3 support from asyncio (GH-232)INADA Naoki2017-04-251-10/+5
|
* Merge 3.5 (issue #27906)Yury Selivanov2016-09-151-1/+1
|\
| * Issue #27906: Fix socket accept exhaustion during high TCP traffic.Yury Selivanov2016-09-151-1/+1
| | | | | | | | Patch by Kevin Conway.
* | Merge 3.5 (asyncio)Yury Selivanov2016-09-121-0/+6
|\ \ | |/
| * asyncio: Add set_protocol / get_protocol methods to TransportsYury Selivanov2016-09-121-0/+6
| |
* | Merge 3.5 (issue #27136, asyncio)Yury Selivanov2016-06-081-8/+1
|\ \ | |/
| * Issue #27136: Fix DNS static resolution; don't use it in getaddrinfoYury Selivanov2016-06-081-8/+1
| | | | | | | | Patch by A. Jesse Jiryu Davis
* | Merge 3.5 (Issue #27041)Yury Selivanov2016-05-161-1/+1
|\ \ | |/
| * Issue #27041: asyncio: Add loop.create_future methodYury Selivanov2016-05-161-1/+1
| |
* | Merge 3.5 (asyncio)Victor Stinner2016-04-011-1/+1
|\ \ | |/
| * asyncio: Don't log ConnectionAbortedErrorVictor Stinner2016-04-011-1/+1
| | | | | | | | | | Issue #26509: In fatal error handlers, don't log ConnectionAbortedError which occur on Windows.
* | Add a source parameter to warnings.warn()Victor Stinner2016-03-221-1/+2
|/ | | | | | | | 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
* asyncio: Skip getaddrinfo if host is already resolved.Yury Selivanov2015-12-171-2/+1
| | | | | | | | | | | | | getaddrinfo takes an exclusive lock on some platforms, causing clients to queue up waiting for the lock if many names are being resolved concurrently. Users may want to handle name resolution in their own code, for the sake of caching, using an alternate resolver, or to measure DNS duration separately from connection duration. Skip getaddrinfo if the "host" passed into create_connection is already resolved. See https://github.com/python/asyncio/pull/302 for details. Patch by A. Jesse Jiryu Davis.
* asyncio: Cleanup Future APIYury Selivanov2015-11-171-1/+2
| | | | See https://github.com/python/asyncio/pull/292 for details.
* asyncio: Add Transport.is_closing()Yury Selivanov2015-11-161-0/+3
| | | | See https://github.com/python/asyncio/pull/291 for details.
* asyncio: Sync with upstream (compat module)Yury Selivanov2015-08-041-2/+2
|
* asyncio: Only call _check_resolved_address() in debug modeVictor Stinner2015-02-041-1/+2
| | | | | | | | | | | | | | | | * _check_resolved_address() is implemented with getaddrinfo() which is slow * If available, use socket.inet_pton() instead of socket.getaddrinfo(), because it is much faster Microbenchmark (timeit) on Fedora 21 (Python 3.4, Linux 3.17, glibc 2.20) to validate the IPV4 address "127.0.0.1" or the IPv6 address "::1": * getaddrinfo() 10.4 usec per loop * inet_pton(): 0.285 usec per loop On glibc older than 2.14, getaddrinfo() always requests the list of all local IP addresses to the kernel (using a NETLINK socket). getaddrinfo() has other known issues, it's better to avoid it when it is possible.
* Issue #23243, asyncio: Emit a ResourceWarning when an event loop or a transportVictor Stinner2015-01-291-0/+11
| | | | is not explicitly closed. Close also explicitly transports in test_sslproto.
* asyncio: SSL transports now clear their reference to the waiterVictor Stinner2015-01-281-1/+1
| | | | | | | * Rephrase also the comment explaining why the waiter is not awaken immediatly. * SSLProtocol.eof_received() doesn't instanciate ConnectionResetError exception directly, it will be done by Future.set_exception(). The exception is not used if the waiter was cancelled or if there is no waiter.
* asyncio: Enhance BaseProactorEventLoop._loop_self_reading()Victor Stinner2015-01-211-3/+9
| | | | | | | | * Handle correctly CancelledError: just exit * On error, log the exception and exit Don't try to close the event loop, it is probably running and so it cannot be closed.
* asyncio: Fix _ProactorBasePipeTransport.close()Victor Stinner2015-01-151-1/+3
| | | | | | | Set the _read_fut attribute to None after cancelling it. This change should fix a race condition with _ProactorWritePipeTransport._pipe_closed().
* asyncio: Fix _ProactorBasePipeTransport.__repr__()Victor Stinner2015-01-151-3/+3
| | | | Check if the _sock attribute is None to check if the transport is closed.
* asyncio: sync with TulipVictor Stinner2015-01-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | * PipeHandle now uses None instead of -1 for a closed handle * Sort imports in windows_utils. * Fix test_events on Python older than 3.5. Skip SSL tests on the ProactorEventLoop if ssl.MemoryIO is missing * Fix BaseEventLoop._create_connection_transport(). Close the transport if the creation of the transport (if the waiter) gets an exception. * _ProactorBasePipeTransport now sets _sock to None when the transport is closed. * Fix BaseSubprocessTransport.close(). Ignore pipes for which the protocol is not set yet (still equal to None). * TestLoop.close() now calls the close() method of the parent class (BaseEventLoop). * Cleanup BaseSelectorEventLoop: create the protocol on a separated line for readability and ease debugging. * Fix BaseSubprocessTransport._kill_wait(). Set the _returncode attribute, so close() doesn't try to terminate the process. * Tests: explicitly close event loops and transports * UNIX pipe transports: add closed/closing in repr(). Add "closed" or "closing" state in the __repr__() method of _UnixReadPipeTransport and _UnixWritePipeTransport classes.
* Issue #22560: New SSL implementation based on ssl.MemoryBIOVictor Stinner2015-01-131-6/+25
| | | | | | | | | | | | | | | | | | | The new SSL implementation is based on the new ssl.MemoryBIO which is only available on Python 3.5. On Python 3.4 and older, the legacy SSL implementation (using SSL_write, SSL_read, etc.) is used. The proactor event loop only supports the new implementation. The new asyncio.sslproto module adds _SSLPipe, SSLProtocol and _SSLProtocolTransport classes. _SSLPipe allows to "wrap" or "unwrap" a socket (switch between cleartext and SSL/TLS). Patch written by Antoine Pitrou. sslproto.py is based on gruvi/ssl.py of the gruvi project written by Geert Jansen. This change adds SSL support to ProactorEventLoop on Python 3.5 and newer! It becomes also possible to implement STARTTTLS: switch a cleartext socket to SSL.
* Issue #22922: Fix ProactorEventLoop.close()Victor Stinner2015-01-131-1/+7
| | | | | Close the IocpProactor before closing the event loop. IocpProactor.close() can call loop.call_soon(), which is forbidden when the event loop is closed.
* asyncio: sync with TulipVictor Stinner2015-01-091-1/+2
| | | | | | | * Tulip issue 184: FlowControlMixin constructor now get the event loop if the loop parameter is not set. Add unit tests to ensure that constructor of StreamReader and StreamReaderProtocol classes get the event loop. * Remove outdated TODO/XXX
* Issue #22926: In debug mode, call_soon(), call_at() and call_later() methods ofVictor Stinner2014-12-261-4/+2
| | | | | | | | | | asyncio.BaseEventLoop now use the identifier of the current thread to ensure that they are called from the thread running the event loop. Before, the get_event_loop() method was used to check the thread, and no exception was raised when the thread had no event loop. Now the methods always raise an exception in debug mode when called from the wrong thread. It should help to notice misusage of the API.
* asyncio, tulip issue 202: Add unit test of pause/resume writing for proactorVictor Stinner2014-12-111-4/+0
| | | | socket transport
* Issue #22922: Fix ProactorEventLoop.close()Victor Stinner2014-12-051-1/+3
| | | | | Call _stop_accept_futures() before sestting the _closed attribute, otherwise call_soon() raises an error.
* asyncio: Move loop attribute to _FlowControlMixinVictor Stinner2014-11-051-2/+1
| | | | | | | | | Move the _loop attribute from the constructor of _SelectorTransport, _ProactorBasePipeTransport and _UnixWritePipeTransport classes to the constructor of the _FlowControlMixin class. Add also an assertion to explicit that the parent class must ensure that the loop is defined (not None)
* asyncio: enhance protocol representationVictor Stinner2014-10-121-1/+7
| | | | Add "closed" or "closing" to repr() of selector and proactor transports
* asyncio: sync with TulipVictor Stinner2014-08-251-11/+13
| | | | | | | | | | | | | | | | | | | | | | | * PipeServer.close() now cancels the "accept pipe" future which cancels the overlapped operation. * Fix _SelectorTransport.__repr__() if the transport was closed * Fix debug log in BaseEventLoop.create_connection(): get the socket object from the transport because SSL transport closes the old socket and creates a new SSL socket object. Remove also the _SelectorSslTransport._rawsock attribute: it contained the closed socket (not very useful) and it was not used. * Issue #22063: socket operations (sock_recv, sock_sendall, sock_connect, sock_accept) of the proactor event loop don't raise an exception in debug mode if the socket are in blocking mode. Overlapped operations also work on blocking sockets. * Fix unit tests in debug mode: mock a non-blocking socket for socket operations which now raise an exception if the socket is blocking. * _fatal_error() method of _UnixReadPipeTransport and _UnixWritePipeTransport now log all exceptions in debug mode * Don't log expected errors in unit tests * Tulip issue 200: _WaitHandleFuture._unregister_wait() now catchs and logs exceptions. * Tulip issue 200: Log errors in debug mode instead of simply ignoring them.