Commit Graph

904 Commits

Author SHA1 Message Date
Kumar Aditya 0448deac70
GH-100113: remove remaining `yield from` usage from `asyncio` tests (#100114) 2022-12-09 09:22:18 +05:30
Fantix King e8fff515f0
Fix `test_run_until_complete_baseexception` test to check for `KeyboardInterrupt` in asyncio (#24477) 2022-12-08 13:51:04 +05:30
Serhiy Storchaka fd38a2f0ec
gh-93453: No longer create an event loop in get_event_loop() (#98440)
asyncio.get_event_loop() now always return either running event loop or
the result of get_event_loop_policy().get_event_loop() call. The latter
should now raise an RuntimeError if no current event loop was set
instead of creating and setting a new event loop.

It affects also a number of asyncio functions and constructors which
call get_event_loop() implicitly: ensure_future(), shield(), gather(),
etc.

DeprecationWarning is no longer emitted if there is no running event loop but
the current event loop was set.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-12-06 18:42:12 +01:00
Serhiy Storchaka 76f43fc09a
gh-60203: Always pass True/False as boolean arguments in tests (GH-99983)
Unless we explicitly test non-bool values.
2022-12-04 14:28:56 +02:00
Kumar Aditya ee60156500
GH-66285: remove redundant `time.sleep` from `test_fork_signal_handling` (GH-99963) 2022-12-02 22:15:36 -08:00
Kumar Aditya 191708c56c
GH-66285: fix forking in asyncio (#99769)
Closes #66285
2022-11-27 11:24:48 +05:30
Kumar Aditya 351842b46a
GH-66285: Revert "fix forking in asyncio" (#99756) 2022-11-24 23:04:21 +05:30
Kumar Aditya 679d963fc8
GH-66285: skip asyncio fork tests for platforms without md5 hash (#99745)
Such buildbots (at the time of writing, only "AMD64 RHEL8 FIPS Only Blake2 Builtin Hash 3.x") cannot use multiprocessing with a fork server, so just skip the test there.
2022-11-24 08:06:06 -08:00
Guido van Rossum 5d09d11aa0
GH-79033: Fix asyncio.Server.wait_closed() (#98582)
It was a no-op when used as recommended (after close()).

I had to debug one test (test__sock_sendfile_native_failure) --
the cleanup sequence for the test fixture was botched.

Hopefully that's not a portend of problems in user code --
this has never worked so people may well be doing this wrong. :-(

Co-authored-by: kumar aditya
2022-11-24 08:32:58 -07:00
Kumar Aditya 0c1fbc17b4
GH-66285: fix forking in `asyncio` (#99539)
`asyncio` now does not shares event loop and signal wakeupfd in forked processes.
2022-11-24 09:10:27 +05:30
Kumar Aditya 619cadcda6
GH-98219: reduce sleep time in `asyncio` subprocess test (#99464) 2022-11-14 11:53:11 -08:00
Kumar Aditya f63002755d
GH-99388: add `loop_factory` parameter to `asyncio.run` (#99462) 2022-11-14 10:18:51 -08:00
Xiao Chen 99972dc745
gh-99357: Close the event loop when it is no longer used in test_uncancel_structured_blocks (#99414) 2022-11-12 12:16:44 -08:00
Kumar Aditya aa874326d8
GH-94597: add deprecation warnings for subclassing `AbstractChildWatcher` (#99386) 2022-11-11 23:17:53 -08:00
Charlie Zhao 3ac8c0ab6e
gh-98793: Fix typecheck in `overlapped.c` (#98835)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-29 21:34:46 -07:00
Kumar Aditya 9bdec0aa45
GH-90352: fix _SelectorDatagramTransport to inherit from DatagramTransport (#98844) 2022-10-29 09:43:42 -07:00
Kumar Aditya 96ae80f1d0
gh-98703: Add tests for closing `_ProactorSocketTransport` with proactor event loop (GH-98730) 2022-10-27 11:07:31 +08:00
Kumar Aditya ad1dc3ebb6
GH-89237: fix hang in proactor `subprocess.wait_closed()` (#98572) 2022-10-24 13:21:42 -07:00
Kumar Aditya 3b2724abcf
GH-98407: fix `test_kill_issue43884` to not leak child processes (#98491) 2022-10-24 10:50:35 -07:00
fancidev 3e82ad05b1
gh-98174: Handle EPROTOTYPE under macOS in test_sendfile_fallback_close_peer_in_the_middle_of_receiving (#98316)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-17 08:45:38 -07:00
Kumar Aditya 72c10d3f1a
GH-98327: Reduce scope of catch_warnings() in _make_subprocess_transport (#98333)
Alas, warnings.catch_warnings() has global scope, not thread scope, so this is still not perfect, but it reduces the time during which warnings are ignored. Better solution welcome.
2022-10-17 08:27:02 -07:00
Kumar Aditya 660f10248b
GH-94597: Deprecate child watcher getters and setters (#98215)
This is the next step for deprecating child watchers.

Until we've removed the API completely we have to use it, so this PR is mostly suppressing a lot of warnings when using the API internally.

Once the child watcher API is totally removed, the two child watcher implementations we actually use and need (Pidfd and Thread) will be turned into internal helpers.
2022-10-15 16:09:30 -07:00
Christoph Hamsen c9ed0327a9
bpo-46364: Use sockets for stdin of asyncio only on AIX (#30596)
Signed-off-by: Christoph Hamsen <hamsen.christoph@posteo.de>
Co-authored-by: July Tikhonov <july.tikh@gmail.com>
2022-10-13 09:11:15 -07:00
Kumar Aditya d8765284f3
GH-94597: deprecate `SafeChildWatcher`, `FastChildWatcher` and `MultiLoopChildWatcher` child watchers (#98089) 2022-10-08 13:52:19 -07:00
Kumar Aditya 8ba9378b16
GH-98023: Change default child watcher to PidfdChildWatcher on supported systems (#98024) 2022-10-07 17:29:09 -07:00
Thomas Grainger 3d8b224547
GH-94182: Run the PidfdChildWatcher on the running loop (#94184)
There is no reason for this watcher to be attached to any particular loop.
This should make it safe to use regardless of the lifetime of the event loop running in the main thread
(relative to other loops).

Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-07 17:24:01 -07:00
Guido van Rossum c06276402b
GH-88968: Reject socket that is already used as a transport (#98010) 2022-10-07 12:56:50 -07:00
Oleg Iarygin f99bb20cde
gh-97983: Revert "Lay the foundation for further work in asyncio.test_streams: port server cases to IsolatedAsyncioTestCase" (#98015)
This PR reverts gh-93369 and gh-97896 because they've made asyncio tests unstable. After these PRs were merged, random GitHub action jobs of random commits started to fail unrelated tests and test framework methods.

The reverting is necessary because such shrapnel failures are a symptom of some underlying bug that must be found and fixed first.

I had a hope that it's a server overload because we already have extremely rare disc access errors. However, one and a half day passed, and the failures continue to emerge both in PRs and commits.

Affected issue: gh-93357.
First reported in https://github.com/python/cpython/pull/97940#issuecomment-1270004134.

* Revert "gh-93357: Port test cases to IsolatedAsyncioTestCase, part 2 (#97896)"

This reverts commit 09aea94d29.

* Revert "gh-93357: Start porting asyncio server test cases to IsolatedAsyncioTestCase (#93369)"

This reverts commit ce8fc186ac.
2022-10-07 07:14:28 -07:00
Guido van Rossum 09de8d7aaf
GH-90985: Revert "Deprecate passing a message into cancel()" (#97999)
Reason: we were too hasty in deprecating this.
We shouldn't deprecate it before we have a replacement.
2022-10-06 17:30:27 -07:00
Kumar Aditya 7015e13797
gh-88050: Fix asyncio subprocess to kill process cleanly when process is blocked (#32073) 2022-10-05 10:15:31 -07:00
Oleg Iarygin 09aea94d29
gh-93357: Port test cases to IsolatedAsyncioTestCase, part 2 (#97896)
This fixes the buildbots.
2022-10-05 07:31:43 -07:00
Guido van Rossum 8079bef56f
GH-96704: Add {Task,Handle}.get_context(), use it in call_exception_handler() (#96756)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-04 23:49:10 -07:00
Oleg Iarygin ce8fc186ac
gh-93357: Start porting asyncio server test cases to IsolatedAsyncioTestCase (#93369)
Lay the foundation for further work in `asyncio.test_streams`.
2022-10-04 10:56:47 -07:00
Łukasz Langa f00645d5db
gh-90908: Document asyncio.Task.cancelling() and asyncio.Task.uncancel() (#95253)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2022-10-01 10:42:36 -07:00
Guido van Rossum 63780f4599
GH-97592: Fix crash in C remove_done_callback due to evil code (#97660)
Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called.
2022-09-30 12:57:09 -07:00
Ofey Chan 83a3de4e06
gh-96348: Deprecate the 3-arg signature of coroutine.throw and generator.throw (GH-96428) 2022-09-30 09:43:02 +01:00
Cyker Way 68c46ae68b
gh-97545: Make Semaphore run faster. (#97549) 2022-09-26 16:38:00 -07:00
Cyker Way 24e0379624
gh-90155: Fix bug in asyncio.Semaphore and strengthen FIFO guarantee (#93222)
The main problem was that an unluckily timed task cancellation could cause
the semaphore to be stuck. There were also doubts about strict FIFO ordering
of tasks allowed to pass.

The Semaphore implementation was rewritten to be more similar to Lock.
Many tests for edge cases (including cancellation) were added.
2022-09-22 09:34:45 -07:00
Guido van Rossum 487135a396
Revert "gh-87079: Warn on unintended signal wakeup fd override in `asyncio` (#96807)" (#96898)
This reverts commit 0587810698.
Reason: This broke buildbots (some warnings added by that commit are turned to errors in the SSL buildbot).
Repro:  ./python Lib/test/ssltests.py
2022-09-17 14:12:45 -07:00
Michel Hidalgo 0587810698
gh-87079: Warn on unintended signal wakeup fd override in `asyncio` (#96807)
Warn on loop initialization, when setting the wakeup fd disturbs a previously set wakeup fd, and on loop closing, when upon resetting the wakeup fd, we find it has been changed by someone else.
2022-09-17 08:07:54 -07:00
Pamela Fox a0ad63e70e
gh-93973: Add all_errors to asyncio.create_connection (#93974)
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
2022-09-04 18:33:50 -07:00
Kumar Aditya e5b2453e61
GH-74116: Allow multiple drain waiters for asyncio.StreamWriter (GH-94705) 2022-08-29 11:31:11 -07:00
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