Commit Graph

862 Commits

Author SHA1 Message Date
Guido van Rossum f51f54f39d
GH-95704: Don't suppress errors from tasks when TG is cancelled (#95761)
When a task catches CancelledError and raises some other error,
the other error should not silently be suppressed.

Any scenario where a task crashes in cleanup upon cancellation
will now result in an ExceptionGroup wrapping the crash(es)
instead of propagating CancelledError and ignoring the side errors.

NOTE: This represents a change in behavior (hence the need to
change several tests).  But it is only an edge case.

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2022-08-16 18:23:06 -07:00
Kumar Aditya 914f6367a0
GH-95899: fix asyncio.Runner to call set_event_loop only once (#95900) 2022-08-15 10:02:47 -07:00
Yury Selivanov 7da4937748
gh-95724: Clarify taskgroups.py license. (#95847) 2022-08-11 16:12:06 -07:00
Fantix King 3a9e1fda7a
gh-95573: Reduce test data size in test_asyncio/test_ssl.py (GH-95668)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-08-05 10:45:36 +02:00
Fantix King e1d68b3ce7
gh-95573: Fix a mistake in asyncio ssl tests suppressing all logs (#95687) 2022-08-05 09:33:35 +02:00
Kumar Aditya 2fef27589e
GH-95289: Always call uncancel() when parent cancellation is requested (#95602)
Co-authored-by: Guido van Rossum <guido@python.org>
2022-08-04 06:57:44 -07:00
Łukasz Langa 0342c93a6b
gh-91323: Revert "Allow overriding a future compliance check in asyncio.Task (GH-32197)" (GH-95442)
This reverts commit d4bb38f82b.
2022-08-04 15:51:38 +02:00
Jo, Yunjin b53aed76d2
gh-95597: Fix typo in Lib directory files (#95599) 2022-08-03 17:16:15 -04:00
Kumar Aditya 54f48844d1
GH-95097: fix `asyncio.run` for tasks without `uncancel` method (#95211)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2022-07-28 08:47:54 -07:00
Thomas Grainger 0c6f898005
gh-95051: ensure that timeouts scheduled with `asyncio.Timeout` that have already expired are deliverered promptly (#95109)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-07-24 13:18:05 -07:00
Thomas Grainger 834bd5dd76
gh-95010: Fix asyncio GenericWatcherTests.test_create_subprocess_fails_with_inactive_watcher (GH-95009)
The test was never run, because it was missing the TestCase class.
The test failed because the wrong attribute was patched.
2022-07-21 14:35:20 +03:00
Thomas Grainger 07aeb7405e
gh-72889: Remove redundant mock.Mock()._is_coroutine = False workarounds (#94926) 2022-07-17 10:21:58 -07:00
Kumar Aditya 86c1df1872
bpo-45924: Fix asyncio incorrect traceback when future's exception is raised multiple times (GH-30274) 2022-07-11 13:32:11 +01:00
Kumar Aditya 14fea6b4d2
GH-93896: AAlways set event loop in asyncio.run and IsolatedAsyncioTestCase (#94593) 2022-07-06 16:18:21 +01:00
Guido van Rossum 594c369949
GH-94398: TaskGroup: Fail create_task() during shutdown (GH-94400)
Once the task group is shutting down, it should not be possible to create a new task.
Here "shutting down" means `self._aborting` is set, indicating that at least one task
has failed and we have cancelled all others.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-30 19:10:46 +02:00
Mehdi ABAAKOUK 4261b6bffc
gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (#94050)
The inspect version was not working with unittest.mock.AsyncMock.

The fix introduces special-casing of AsyncMock in
`inspect.iscoroutinefunction` equivalent to the one
performed in `asyncio.iscoroutinefunction`.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-30 19:08:38 +02:00
Victor Stinner 47e35625ff
gh-84623: Remove unused imports (#94132) 2022-06-22 19:14:27 +02:00
Victor Stinner c5b750dc0b
gh-93852: Add test.support.create_unix_domain_name() (#93914)
test_asyncio, test_logging, test_socket and test_socketserver now
create AF_UNIX domains in the current directory to no longer fail
with OSError("AF_UNIX path too long") if the temporary directory (the
TMPDIR environment variable) is too long.

Modify the following tests to use create_unix_domain_name():

* test_asyncio
* test_logging
* test_socket
* test_socketserver

test_asyncio.utils: remove unused time import.
2022-06-17 13:16:51 +02:00
Victor Stinner 41fccd23e9
test_asyncio: run_until() implements exponential sleep (#93866)
run_until() of test.test_asyncio.utils now uses an exponential sleep
delay (max: 1 second), rather than a fixed delay of 1 ms. Similar
design than support.sleeping_retry() wait strategy that applies
exponential backoff.
2022-06-15 18:28:00 +02:00
Kumar Aditya b415c5f1aa
GH-93850: Fix test_asyncio exception ignored tracebacks (#93854) 2022-06-15 16:41:47 +02:00
Victor Stinner 0ba80273f2
Use support.sleeping_retry() and support.busy_retry() (#93848)
* Replace time.sleep(0.010) with sleeping_retry() to
  use an exponential sleep.
* support.wait_process(): reuse sleeping_retry().
* _test_eintr: remove unused variables.
2022-06-15 14:09:56 +02:00
Victor Stinner 3ceb4b8d3a
gh-84623: Remove unused imports in tests (#93772) 2022-06-13 16:56:03 +02:00
Cyker Way 9081bbd036
gh-93247: Fix assert function in asyncio locks test (#93248) 2022-06-05 18:19:18 -07:00
Akuli a4974003ec
gh-93124: Fix typos in comments (GH-93125)
Fixes #93124

Automerge-Triggered-By: GH:rhettinger
2022-05-25 08:34:14 -07:00
Victor Stinner 1d1929fcb5
gh-90978: asyncio TestSSL uses SHORT_TIMEOUT (#92642)
TestSSL of asyncio now uses support.SHORT_TIMEOUT rather than
hardcoded timeouts like 5, 10 or 40 seconds.
2022-05-11 23:25:56 +02:00
Victor Stinner 973a5203c1
gh-90978: test_ssl of test_asyncio uses LONG_TIMEOUT (#92402)
On slow buildbot workers, some test_ssl tests fail randomly because
of short timeout (30 seconds). Use support.LONG_TIMEOUT instead which
is longer and also adjusted (by regrtest --timeout option) on
buildbot workers known to be slow.
2022-05-06 15:18:56 +01:00
Gregory P. Smith f6dd14c653
gh-82616: Add process_group support to subprocess.Popen (#23930)
One more thing that can help prevent people from using `preexec_fn`.

Also adds conditional skips to two tests exposing ASAN flakiness on the Ubuntu 20.04 Address Sanitizer Github CI system. When that build is run on more modern systems the "problem" does not show up. It seems ASAN implementation related.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-05 16:22:32 -07:00
David Hewitt 1cd8c29dac
gh-91880: add try/except around `signal.signal` (#91881)
Fixes gh-91880.
2022-04-25 08:56:20 -07:00
Serhiy Storchaka 090721721b
Simplify testing the warning filename (GH-91868)
The context manager result has the "filename" attribute.
2022-04-24 10:23:59 +03:00
Oleg Iarygin 6217864fe5
gh-79156: Add start_tls() method to streams API (#91453)
The existing event loop `start_tls()` method is not sufficient for
connections using the streams API. The existing StreamReader works
because the new transport passes received data to the original protocol.
The StreamWriter must then write data to the new transport, and the
StreamReaderProtocol must be updated to close the new transport
correctly.

The new StreamWriter `start_tls()` updates itself and the reader
protocol to the new SSL transport.

Co-authored-by: Ian Good <icgood@gmail.com>
2022-04-15 14:23:14 +02:00
Andrew Svetlov d4bb38f82b
bpo-47167: Allow overriding a future compliance check in asyncio.Task (GH-32197) 2022-04-01 04:25:15 +03:00
Andrew Svetlov f08a191882
bpo-39622: Interrupt the main asyncio task on Ctrl+C (GH-32105)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-30 15:15:06 +03:00
Andrew Svetlov bad6ffaa64
bpo-47062: Rename factory argument to loop_factory (GH-32113) 2022-03-26 00:26:23 +02:00
Duprat d03acd7270
bpo-43352: Add a Barrier object in asyncio lib (GH-24903)
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-26 00:01:21 +02:00
Andrew Svetlov 20e6e5636a
bpo-47118: Fix asyncio.Runner tests error (32117) 2022-03-25 19:59:29 +02:00
Andrew Svetlov 4119d2d7c9
bpo-47062: Implement asyncio.Runner context manager (GH-31799)
Co-authored-by: Zachary Ware <zach@python.org>
2022-03-24 21:51:16 +02:00
Andrew Svetlov ff619c7dfe
bpo-47104: Rewrite asyncio.to_thread tests to use IsolatedAsyncioTestCase (GH-32086) 2022-03-23 23:17:07 +02:00
Andrew Svetlov 0360e9f346
bpo-46829: Deprecate passing a message into Future.cancel() and Task.cancel() (GH-31840)
After a long deliberation we ended up feeling that the message argument for Future.cancel(), added in 3.9, was a bad idea, so we're deprecating it in 3.11 and plan to remove it in 3.13.
2022-03-23 08:43:05 -07:00
Andrew Svetlov 32e77154dd
bpo-45997: Fix asyncio.Semaphore re-acquiring order (GH-31910)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-22 16:02:51 +02:00
Andrew Svetlov 673755bfba
bpo-47076: Make asyncio.Queue stable on slow test boxes (GH-32040) 2022-03-22 16:00:23 +02:00
Christian Heimes deeaac49e2
bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)
- Add requires_fork and requires_subprocess to more tests
- Skip extension import tests if dlopen is not available
- Don't assume that _testcapi is a shared extension
- Skip a lot of socket tests that don't work on Emscripten
- Skip mmap tests, mmap emulation is incomplete
- venv does not work yet
- Cannot get libc from executable

The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
2022-03-22 03:04:36 -07:00
Andrew Svetlov 903f0a02c1
bpo-34790: Remove passing coroutine objects to asyncio.wait() (GH-31964)
Co-authored-by: Yury Selivanov <yury@edgedb.com>
2022-03-17 22:51:40 +02:00
Andrew Svetlov a7c5414832
bpo-47038: Increase a test timeout for slow CI machines (GH-31951) 2022-03-17 02:54:36 +02:00
Andrew Svetlov 3dd9bfac04
bpo-47038: Rewrite missed asyncio.wait_for test to use IsolatedAnsyncioTestCase (GH-31946) 2022-03-17 01:20:29 +02:00
Andrew Svetlov dd0082c627
bpo-47038: Rewrite asyncio.wait_for test to use IsolatedAsyncioTestCase (GH-31942) 2022-03-16 21:49:18 +02:00
Andrew Svetlov e707ceb6e4
Rewrite asyncio.Queue tests with IsolatedAsyncioTestCace (#31935) 2022-03-16 16:59:12 +02:00
Maximilian Hils 70155412f1
bpo-43253: Don't call shutdown() for invalid socket handles (GH-31892) 2022-03-15 16:59:02 +02:00
Andrew Svetlov 9523c0d84f
bpo-46994: Accept explicit contextvars.Context in asyncio create_task() API (GH-31837) 2022-03-14 13:54:13 +02:00
Alex Grönholm 9f04ee569c
bpo-46805: Add low level UDP socket functions to asyncio (GH-31455) 2022-03-13 18:42:29 +02:00
Andrew Svetlov 7e473e94a5
bpo-46995: Deprecate missing asyncio.Task.set_name() for third-party task implementations (GH-31838)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-13 18:34:46 +02:00