cpython/Lib/test/test_asyncio
Elvis Pranskevichus e2b340ab41 bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216)
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.
2018-05-29 17:31:01 -04:00
..
__init__.py bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
__main__.py Issue #22002: Make full use of test discovery in test sub-packages. 2014-07-23 12:00:29 -05:00
echo.py
echo2.py
echo3.py
functional.py Make asyncio tests run when there's no SSL module (#5196) 2018-01-15 17:56:32 -05:00
keycert3.pem
pycacert.pem
ssl_cert.pem
ssl_key.pem
test_base_events.py bpo-32410: Avoid blocking on file IO in sendfile fallback code (GH-7172) 2018-05-28 18:31:55 -04:00
test_buffered_proto.py bpo-33654: Support BufferedProtocol in set_protocol() and start_tls() (GH-7130) 2018-05-28 14:31:28 -04:00
test_context.py bpo-32630: Use contextvars in decimal (GH-5278) 2018-01-27 13:46:46 -05:00
test_events.py bpo-33353: test_asyncio use set_write_buffer_limits() (GH-7200) 2018-05-29 16:02:07 +02:00
test_futures.py bpo-32643: Drop support for a few private Task and Future APIs. (#5293) 2018-01-24 11:31:01 -05:00
test_locks.py bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216) 2018-05-29 17:31:01 -04:00
test_pep492.py bpo-32591: Add native coroutine origin tracking (#5250) 2018-01-21 09:44:07 -05:00
test_proactor_events.py bpo-33654: Support BufferedProtocol in set_protocol() and start_tls() (GH-7130) 2018-05-28 14:31:28 -04:00
test_queues.py bpo-32574: Fix leaks in asyncio.Queue.put() and .get() (#5208) 2018-01-25 18:45:43 -05:00
test_runners.py bpo-32314: Fix asyncio.run() to cancel runinng tasks on shutdown (#5262) 2018-01-21 14:56:59 -05:00
test_selector_events.py bpo-33654: Support BufferedProtocol in set_protocol() and start_tls() (GH-7130) 2018-05-28 14:31:28 -04:00
test_server.py bpo-32662: Try making test_asyncio.test_server more reliable (#5338) 2018-01-26 01:30:57 -05:00
test_sslproto.py bpo-33654: Support protocol type switching in SSLTransport.set_protocol() (#7194) 2018-05-29 12:02:40 +03:00
test_streams.py bpo-32391: Implement StreamWriter.wait_closed() (#5281) 2018-01-25 00:30:30 +02:00
test_subprocess.py Attempt to fix test_stdin_broken_pipe on Travis (#7210) 2018-05-29 13:40:47 -04:00
test_tasks.py bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216) 2018-05-29 17:31:01 -04:00
test_transports.py Improve test coverage (#4924) 2017-12-19 08:51:16 +02:00
test_unix_events.py bpo-22087: Fix Policy.get_event_loop() to detect fork (GH-7208) 2018-05-29 15:38:07 -04:00
test_windows_events.py bpo-32327: Convert asyncio functions documented as coroutines to coroutines. (#4872) 2017-12-14 20:53:26 -05:00
test_windows_utils.py bpo-32273: Move asyncio.test_utils to test.test_asyncio (#4785) 2017-12-11 10:04:40 -05:00
utils.py bpo-33618: Enable TLS 1.3 in tests (GH-7079) 2018-05-23 22:24:45 +02:00