summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_events.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.6] bpo-31250: test_asyncio: fix dangling threads (#3517)Victor Stinner2017-09-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | * bpo-31250, test_asyncio: fix dangling threads (#3252) * Explicitly call shutdown(wait=True) on executors to wait until all threads complete to prevent side effects between tests. * Fix test_loop_self_reading_exception(): don't mock loop.close(). Previously, the original close() method was called rather than the mock, because how set_event_loop() registered loop.close(). (cherry picked from commit 16432beadb8eba079c9786cc0c0eaacfd9fd2f7b) * bpo-31250, test_asyncio: fix EventLoopTestsMixin.tearDown() (#3264) Call doCleanups() to close the loop after calling executor.shutdown(wait=True): see TestCase.set_event_loop() of asyncio.test_utils. Replace also gc.collect() with support.gc_collect(). (cherry picked from commit e8a533fbc734af6eeb389202ba6c6e9c2548027f)
* bpo-31034: Reliable signal handler for test_asyncio (#2867) (#2876)Victor Stinner2017-07-261-13/+20
| | | | | | | | | | * bpo-31034: Reliable signal handler for test_asyncio Don't rely on the current SIGHUP signal handler, make sure that it's set to the "default" signal handler: SIG_DFL. * Add comments (cherry picked from commit 830080913c22a9834d310294b9f7653234dc6a59)
* bpo-30110: fix resource leak in test_asyncio.test_events (#1413) (#1584)Xiang Zhang2017-05-151-1/+3
|
* bpo-29703: asyncio: Fix creating new event loops in child processes. (#404) ↵Yury Selivanov2017-03-031-0/+22
| | | | (#410)
* Issue #28652: Make loop methods reject socket kinds they do not support.Yury Selivanov2016-11-091-3/+8
|
* asyncio: Fix _format_coroutine for coroutine-like objects w/o __name__Yury Selivanov2016-11-091-2/+6
| | | | | | Some built-in coroutine-like objects might not have __name__ or __qualname__. A good example of such are 'asend', 'aclose' and 'athrow' coroutine methods of asynchronous generators.
* Issue #28613: Expose asyncio._get_running_loop() and _set_running_loop()Yury Selivanov2016-11-081-0/+4
|
* Issue #28613: Fix get_event_loop() to return the current loopYury Selivanov2016-11-041-0/+23
| | | | when called from coroutines or callbacks.
* Issue #28600: Optimize loop.call_soon().Yury Selivanov2016-11-031-7/+0
| | | | | Run expensive type checks only in debug mode. In addition, stop supporting passing handles to loop.run_in_executor.
* Issue #28372: Fix asyncio to support formatting of non-python coroutinesYury Selivanov2016-10-051-0/+34
|
* Issue #26654: Inspect functools.partial in asyncio.Handle.__repr__.Yury Selivanov2016-09-151-1/+8
| | | | Patch by iceboy.
* Merge asyncio upstream.Guido van Rossum2016-09-091-1/+1
|
* Don't select for read on character devices in _UnixWritePipeTransport.Guido van Rossum2016-08-311-0/+75
| | | | Upstream https://github.com/python/asyncio/pull/374 by Ron Frederick.
* Issue #27907: variable rename. (Ville Skyttä)Guido van Rossum2016-08-311-2/+2
|
* Issue #27392: Add loop.connect_accepted_socket().Yury Selivanov2016-07-121-0/+79
| | | | Patch by Jim Fulton.
* Issue #27136: Fix DNS static resolution; don't use it in getaddrinfoYury Selivanov2016-06-081-19/+0
| | | | Patch by A. Jesse Jiryu Davis
* asyncio: Fix unix pipe transport 'repr' methodsYury Selivanov2016-05-131-0/+35
| | | | | Patch by Vincent Michel. See also https://github.com/python/asyncio/pull/326
* asyncio: ease the cert failed regexYury Selivanov2016-05-131-2/+2
| | | | Patch by Philip Jenvey
* asyncio: Remove duplicate bind addresses in create_server.Yury Selivanov2016-03-021-10/+13
| | | | Patch by Sebastien Bourdeauducq (issue #26338)
* Make the error message regex more lenient so that it matches bothGregory P. Smith2016-01-161-2/+2
| | | | | "certificate verify failed " and "CERTIFICATE_VERIFY_FAILED " as some SSL libraries use different text than OpenSSL.
* asyncio: Skip getaddrinfo if host is already resolved.Yury Selivanov2015-12-171-4/+0
| | | | | | | | | | | | | 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.
* Issue #23972: updates to asyncio datagram API. By Chris Laws.Guido van Rossum2015-10-051-0/+52
|
* Issue #23630: Fix test_asyncio on WindowsVictor Stinner2015-09-211-0/+1
| | | | The proactor event loop requires also to mock loop._stop_serving.
* Issue #25114: Fix test_asyncioVictor Stinner2015-09-211-3/+2
| | | | ssl.SSLContext() does not always disable compression. Fix unit test.
* Issue #23630, asyncio: host parameter of loop.create_server() can now be aVictor Stinner2015-09-211-0/+33
| | | | sequence of strings. Patch written by Yann Sionneau.
* Issue #25114, asyncio: add ssl_object extra info to SSL transportsVictor Stinner2015-09-211-12/+63
| | | | | | This info is required on Python 3.5 and newer to get specific information on the SSL object, like getting the binary peer certificate (instead of getting it as text).
* asyncio: Only call _check_resolved_address() in debug modeVictor Stinner2015-02-041-0/+4
| | | | | | | | | | | | | | | | * _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.
* asyncio: sync with TulipVictor Stinner2015-01-291-17/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #23347: send_signal(), kill() and terminate() methods of BaseSubprocessTransport now check if the transport was closed and if the process exited. Issue #23347: Refactor creation of subprocess transports. Changes on BaseSubprocessTransport: * Add a wait() method to wait until the child process exit * The constructor now accepts an optional waiter parameter. The _post_init() coroutine must not be called explicitly anymore. It makes subprocess transports closer to other transports, and it gives more freedom if we want later to change completly how subprocess transports are created. * close() now kills the process instead of kindly terminate it: the child process may ignore SIGTERM and continue to run. Call explicitly terminate() and wait() if you want to kindly terminate the child process. * close() now logs a warning in debug mode if the process is still running and needs to be killed * _make_subprocess_transport() is now fully asynchronous again: if the creation of the transport failed, wait asynchronously for the process eixt. Before the wait was synchronous. This change requires close() to *kill*, and not terminate, the child process. * Remove the _kill_wait() method, replaced with a more agressive close() method. It fixes _make_subprocess_transport() on error. BaseSubprocessTransport.close() calls the close() method of pipe transports, whereas _kill_wait() closed directly pipes of the subprocess.Popen object without unregistering file descriptors from the selector (which caused severe bugs). These changes simplifies the code of subprocess.py.
* asyncio: sync with TulipVictor Stinner2015-01-291-13/+24
| | | | | | | | | * Cleanup gather(): use cancelled() method instead of using private Future attribute * Fix _UnixReadPipeTransport and _UnixWritePipeTransport. Only start reading when connection_made() has been called. * Issue #23333: Fix BaseSelectorEventLoop._accept_connection(). Close the transport on error. In debug mode, log errors using call_exception_handler()
* asyncio: sync with TulipVictor Stinner2015-01-141-0/+22
| | | | | | | | | | | | | | | | | | | | | | | * 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-10/+48
| | | | | | | | | | | | | | | | | | | 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.
* asyncio: sync with TulipVictor Stinner2014-12-261-1/+1
| | | | | * Fix pyflakes warnings: remove unused imports and variables * asyncio.test_support now uses test.support and test.script_helper if available
* asyncio: sync with TulipVictor Stinner2014-12-181-1/+4
|
* Issue #23074: asyncio.get_event_loop() now raises an exception if the threadVictor Stinner2014-12-181-2/+2
| | | | has no event loop even if assertions are disabled.
* Closes #22922: More EventLoop methods fail if the loop is closed. Initial patchVictor Stinner2014-12-041-1/+34
| | | | | | | written by Torsten Landschoff. create_task(), call_at(), call_soon(), call_soon_threadsafe() and run_in_executor() now raise an error if the event loop is closed.
* don't require OpenSSL SNI to pass hostname to ssl functions (#22921)Benjamin Peterson2014-11-231-8/+0
| | | | Patch by Donald Stufft.
* asyncio, test_events: Ignore the "SSL handshake failed" log in debug modeVictor Stinner2014-11-201-1/+3
|
* asyncio: Fix formatting of the "Future exception was never retrieved" inVictor Stinner2014-11-201-16/+18
| | | | release mode
* Closes #22784: fix test_asyncio when the ssl module isn't availableAntoine Pitrou2014-11-051-8/+9
|
* Issue #22641: In asyncio, the default SSL context for client connections is ↵Antoine Pitrou2014-10-151-10/+38
| | | | now created using ssl.create_default_context(), for stronger security.
* asyncio: Improve canceled timer handles cleanup. Closes issue #22448.Yury Selivanov2014-09-251-3/+11
| | | | Patch by Joshua Moore-Oliva.
* asyncio, Tulip issue 206: In debug mode, keep the callback in theVictor Stinner2014-09-171-4/+5
| | | | representation of Handle and TimerHandle after cancel().
* asyncio: sync with TulipVictor Stinner2014-08-251-16/+20
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* Close #22063: socket operations (socket,recv, sock_sendall, sock_connect,Victor Stinner2014-07-291-0/+18
| | | | | sock_accept) now raise an exception in debug mode if sockets are in blocking mode.
* asyncio tests: make quiet the logs of SSL handshake failures when running testsVictor Stinner2014-07-141-10/+13
| | | | in debug mode
* asyncio: sync with TulipVictor Stinner2014-07-111-1/+1
| | | | | | | | | | * Tulip issue #182: Improve logs of BaseEventLoop._run_once() - Don't log non-blocking poll - Only log polling with a timeout if it gets events or if it timed out after more than 1 second. * Fix some pyflakes warnings: remove unused imports
* asyncio: sync with TulipVictor Stinner2014-07-101-12/+54
| | | | | | | | - Issues #21936, #21163: Fix sporadic failures of test_future_exception_never_retrieved() - Handle.cancel() now clears references to callback and args - In debug mode, repr(Handle) now contains the location where the Handle was created.
* asyncion, Tulip issue 181: BaseEventLoop.create_datagram_endpoint() now waitsVictor Stinner2014-07-081-0/+10
| | | | | until protocol.connection_made() has been called. Document also why transport constructors use a waiter.
* asyncio: sync with TulipVictor Stinner2014-07-081-0/+14
| | | | | | | | | | | - Tulip issue 185: Add a create_task() method to event loops. The create_task() method can be overriden in custom event loop to implement their own task class. For example, greenio and Pulsar projects use their own task class. The create_task() method is now preferred over creating directly task using the Task class. - tests: fix a warning - fix typo in the name of a test function - Update AbstractEventLoop: add new event loop methods; update also the unit test
* asyncio, Tulip issue 137: In debug mode, save traceback where Future, Task andVictor Stinner2014-06-271-3/+34
| | | | | | | | | | | Handle objects are created. Pass the traceback to call_exception_handler() in the 'source_traceback' key. The traceback is truncated to hide internal calls in asyncio, show only the traceback from user code. Add tests for the new source_traceback, and a test for the 'Future/Task exception was never retrieved' log.