summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
Commit message (Collapse)AuthorAgeFilesLines
* asyncio: Fix _SelectorTransport.__repr__() if the event loop is closedVictor Stinner2015-03-271-0/+5
|
* asyncio: Fix warning in test_close_kill_running()Victor Stinner2015-02-171-0/+1
| | | | | Read process exit status to avoid the "Caught subprocess termination from unknown pid" message.
* Issue #23475, asyncio: Fix test_close_kill_running()Victor Stinner2015-02-171-2/+10
| | | | | | Really kill the child process, don't mock completly the Popen.kill() method. This change fix memory leaks and reference leaks.
* asyncio, Tulip issue 220: Merge JoinableQueue with Queue.Victor Stinner2015-02-171-5/+5
| | | | | | | | | | | | | | Merge JoinableQueue with Queue. To more closely match the standard Queue, asyncio.Queue has "join" and "task_done". JoinableQueue is deleted. Docstring for Queue.join shouldn't mention threads. Restore JoinableQueue as a deprecated alias for Queue. To more closely match the standard Queue, asyncio.Queue has "join" and "task_done". JoinableQueue remains as a deprecated alias for Queue to avoid needlessly breaking too much code that depended on it. Patch written by A. Jesse Jiryu Davis <jesse@mongodb.com>.
* Use os.devnull instead of hardcoded '/dev/null'.Serhiy Storchaka2015-02-151-3/+3
|
* asyncio: BaseSubprocessTransport.close() doesn't try to kill the process if itVictor Stinner2015-02-101-0/+55
| | | | already finished
* 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.
* Issue #23347, asyncio: send_signal(), terminate(), kill() don't check if theVictor Stinner2015-01-301-16/+0
| | | | | | | transport was closed. The check broken a Tulip example and this limitation is arbitrary. Check if _proc is None should be enough. Enhance also close(): do nothing when called the second time.
* asyncio: Fix ResourceWarning in test_subprocess.test_proc_exit()Victor Stinner2015-01-291-0/+2
|
* asyncio: sync with TulipVictor Stinner2015-01-292-17/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Issue #23243, asyncio: Emit a ResourceWarning when an event loop or a transportVictor Stinner2015-01-292-5/+8
| | | | is not explicitly closed. Close also explicitly transports in test_sslproto.
* asyncio: sync with TulipVictor Stinner2015-01-292-31/+35
| | | | | | | | | * 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-291-1/+14
| | | | | | | | | | * _SelectorTransport constructor: extra parameter is now optional * Fix _SelectorDatagramTransport constructor. Only start reading after connection_made() has been called. * Fix _SelectorSslTransport.close(). Don't call protocol.connection_lost() if protocol.connection_made() was not called yet: if the SSL handshake failed or is still in progress. The close() method can be called if the creation of the connection is cancelled, by a timeout for example.
* asyncio: Fix _SelectorSocketTransport constructorVictor Stinner2015-01-281-5/+11
| | | | | Only start reading when connection_made() has been called: protocol.data_received() must not be called before protocol.connection_made().
* asyncio: Fix SSLProtocol.eof_received()Victor Stinner2015-01-281-11/+29
| | | | Wake-up the waiter if it is not done yet.
* asyncio: sync with TulipVictor Stinner2015-01-271-0/+5
| | | | | | | | | | * Remove unused SSLProtocol._closing attribute * test_sslproto: skip test if ssl module is missing * Python issue #23208: Don't use the traceback of the current handle if we already know the traceback of the source. The handle may be more revelant, but having 3 tracebacks (handle, source, exception) becomes more difficult to read. The handle may be preferred later but it requires more work to make this choice.
* Issue #23293, asyncio: Rewrite IocpProactor.connect_pipe() as a coroutineVictor Stinner2015-01-261-0/+13
| | | | | | | Use a coroutine with asyncio.sleep() instead of call_later() to ensure that the schedule call is cancelled. Add also a unit test cancelling connect_pipe().
* asyncio: pyflakes, remove unused importVictor Stinner2015-01-211-9/+1
| | | | tests: Remove unused function; inline another function
* asyncio: Enhance BaseProactorEventLoop._loop_self_reading()Victor Stinner2015-01-211-2/+3
| | | | | | | | * 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.
* Issue #22685: Fix test_pause_reading() of asyncio/test_subprocessVictor Stinner2015-01-151-2/+12
| | | | | | | Override the connect_read_pipe() method of the loop to mock immediatly pause_reading() and resume_reading() methods. The test failed randomly on FreeBSD 9 buildbot and on Windows using trollius.
* Closes #23219: cancelling asyncio.wait_for() now cancels the taskVictor Stinner2015-01-151-0/+27
|
* asyncio: Close transports in testsVictor Stinner2015-01-154-3/+15
| | | | | | | | | * Use test_utils.run_briefly() to execute pending calls to really close transports * sslproto: mock also _SSLPipe.shutdown(), it's need to close the transport * pipe test: the test doesn't close explicitly the PipeHandle, so ignore the warning instead * test_popen: use the context manager ("with p:") to explicitly close pipes
* Issue #23243: Close explicitly transports in asyncio testsVictor Stinner2015-01-153-277/+226
|
* Issue #23243: Close explicitly event loops in asyncio testsVictor Stinner2015-01-153-1/+20
|
* Issue #23243: Fix asyncio._UnixWritePipeTransport.close()Victor Stinner2015-01-151-0/+3
| | | | | Do nothing if the transport is already closed. Before it was not possible to close the transport twice.
* asyncio: sync with TulipVictor Stinner2015-01-145-0/+26
| | | | | | | | | | | | | | | | | | | | | | | * 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 #23197, asyncio: On SSL handshake failure, check if the waiter isVictor Stinner2015-01-142-4/+61
| | | | | | | cancelled before setting its exception. * Add unit tests for this case. * Cleanup also sslproto.py
* Python issue #23173: sync with TulipVictor Stinner2015-01-141-0/+36
| | | | | | | | * If an exception is raised during the creation of a subprocess, kill the subprocess (close pipes, kill and read the return status). Log an error in such case. * Fix SubprocessStreamProtocol.connection_made() to handle cancelled waiter. Add unit test cancelling subprocess methods.
* Issue #22560: New SSL implementation based on ssl.MemoryBIOVictor Stinner2015-01-132-11/+53
| | | | | | | | | | | | | | | | | | | 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.
* Tulip issue 184: Fix test_pipe() on WindowsVictor Stinner2015-01-131-1/+2
| | | | Pass explicitly the event loop to StreamReaderProtocol.
* asyncio: sync with TulipVictor Stinner2015-01-091-0/+19
| | | | | | | * 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
* asyncio: Truncate to 80 columnsVictor Stinner2015-01-085-18/+37
|
* Issue #23140, asyncio: Simplify the unit testVictor Stinner2015-01-061-8/+6
|
* Issue #23140, asyncio: Fix cancellation of Process.wait(). Check the state ofVictor Stinner2015-01-061-0/+28
| | | | the waiter future before setting its result.
* Issue #22926: In debug mode, call_soon(), call_at() and call_later() methods ofVictor Stinner2014-12-263-39/+66
| | | | | | | | | | 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: sync with TulipVictor Stinner2014-12-268-22/+16
| | | | | * Fix pyflakes warnings: remove unused imports and variables * asyncio.test_support now uses test.support and test.script_helper if available
* asyncio: IocpProactor.wait_for_handle() test now also checks the result of theVictor Stinner2014-12-191-2/+6
| | | | future
* asyncio: sync with TulipVictor Stinner2014-12-186-16/+37
|
* 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.
* asyncio, tulip issue 209: Fix subprocess for close_fds=False on Python 3.3Victor Stinner2014-12-111-0/+21
| | | | Mark the write end of the stdin pipe as non-inheritable.
* asyncio, tulip issue 202: Add unit test of pause/resume writing for proactorVictor Stinner2014-12-111-0/+82
| | | | socket transport
* Closes #22429, asyncio: Fix EventLoop.run_until_complete(), don't stop theVictor Stinner2014-12-051-0/+25
| | | | | event loop if a BaseException is raised, because the event loop is already stopped.
* 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.
* Issue #22685: Fix test_pause_reading() of asyncio test_subprocessVictor Stinner2014-12-041-0/+2
| | | | | * mock also resume_reading() * ensure that resume_reading() is called
* Removed duplicated words in in comments and docs.Serhiy Storchaka2014-12-011-1/+1
|
* Issue #22685: Debug test_pause_reading() on FreeBSDVictor Stinner2014-11-281-7/+10
|
* Closes #22685, asyncio: Set the transport of stdout and stderr StreamReaderVictor Stinner2014-11-251-0/+32
| | | | | objects in the SubprocessStreamProtocol. It allows to pause the transport to not buffer too much stdout or stderr data.
* don't require OpenSSL SNI to pass hostname to ssl functions (#22921)Benjamin Peterson2014-11-232-9/+1
| | | | Patch by Donald Stufft.
* asyncio: Coroutine objects are now rejected with a TypeError by the followingVictor Stinner2014-11-202-15/+25
| | | | | | | | | | | | | | functions: * add_signal_handler() * call_at() * call_later() * call_soon() * call_soon_threadsafe() * run_in_executor() Fix also the error message of add_signal_handler() (fix the name of the function).
* asyncio, test_events: Ignore the "SSL handshake failed" log in debug modeVictor Stinner2014-11-201-1/+3
|