Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_asyncio: test_unhandled_exceptions() fails on x86-64 macOS 3.x buildbot #111644

Closed
vstinner opened this issue Nov 2, 2023 · 5 comments
Closed
Labels
tests Tests in the Lib/test dir topic-asyncio

Comments

@vstinner
Copy link
Member

vstinner commented Nov 2, 2023

Apparently, the test is new and was added by PR #111601.

cc @kumaraditya303

Logs:

test_unhandled_exceptions (test.test_asyncio.test_streams.StreamTests.test_unhandled_exceptions) ... Warning -- threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 2)
Warning -- Dangling thread: <_MainThread(MainThread, started 4648830464)>
ok

build: https://buildbot.python.org/all/#/builders/366/builds/5796

Linked PRs

@vstinner
Copy link
Member Author

vstinner commented Nov 2, 2023

Oh, test fails on tons of buildbots: #111601 (comment)

@kumaraditya303
Copy link
Contributor

I am not able to reproduce it on my system. Also I don't understand what Warning -- Dangling thread: <_MainThread(MainThread, started 4648830464)> means, how can main thread be considered dangling?

@vstinner
Copy link
Member Author

vstinner commented Nov 3, 2023

I am not able to reproduce it on my system. Also I don't understand what Warning -- Dangling thread: <_MainThread(MainThread, started 4648830464)> means,

It usually means that a test spawns a thread and don't fully wait until the thread completes.

vstinner added a commit to vstinner/cpython that referenced this issue Nov 3, 2023
Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.
@vstinner
Copy link
Member Author

vstinner commented Nov 3, 2023

I can reproduce the issue with the command:

./python -m test test_asyncio.test_streams -m test_unhandled_exceptions -v -j10 --fail-env-changed -F

vstinner added a commit to vstinner/cpython that referenced this issue Nov 3, 2023
Copy the list of dangling thread to provide a consistent output
between the warning and the "Dangling thread" listing.
vstinner added a commit to vstinner/cpython that referenced this issue Nov 3, 2023
Copy the list of dangling thread to provide a consistent output
between the warning and the "Dangling thread" listing.
vstinner added a commit to vstinner/cpython that referenced this issue Nov 3, 2023
Copy the list of dangling threads to make sure that the list of
"Dangling thread" is complete. Previously, the list was incomplete if
threads completed just before the list is displayed.

Changes:

* Reformat the warning to make it easier to understand.
* Use support.sleeping_retry().
* threading_cleanup() no longer copies threading._dangling: it only
  counts the number of dangling thread.
* Remove support.gc_support() call.
vstinner added a commit to vstinner/cpython that referenced this issue Nov 3, 2023
Copy the list of dangling threads to make sure that the list of
"Dangling thread" is complete. Previously, the list was incomplete if
threads completed just before the list is displayed.

Changes:

* Reformat the warning to make it easier to understand.
* Use support.sleeping_retry().
* threading_cleanup() no longer copies threading._dangling: it only
  counts the number of dangling thread.
* Remove support.gc_support() call.
vstinner added a commit that referenced this issue Nov 4, 2023
Copy the list of dangling threads to make sure that the list of
"Dangling thread" is complete. Previously, the list was incomplete if
threads completed just before the list was displayed.

Changes:

* Rewrite the warning to make it easier to understand.
* Use support.sleeping_retry().
* threading_cleanup() no longer copies threading._dangling,
  but only counts the number of dangling thread.
* Remove support.gc_support() call.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 4, 2023
Copy the list of dangling threads to make sure that the list of
"Dangling thread" is complete. Previously, the list was incomplete if
threads completed just before the list was displayed.

Changes:

* Rewrite the warning to make it easier to understand.
* Use support.sleeping_retry().
* threading_cleanup() no longer copies threading._dangling,
  but only counts the number of dangling thread.
* Remove support.gc_support() call.
(cherry picked from commit f62c7cc)

Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 4, 2023
Copy the list of dangling threads to make sure that the list of
"Dangling thread" is complete. Previously, the list was incomplete if
threads completed just before the list was displayed.

Changes:

* Rewrite the warning to make it easier to understand.
* Use support.sleeping_retry().
* threading_cleanup() no longer copies threading._dangling,
  but only counts the number of dangling thread.
* Remove support.gc_support() call.
(cherry picked from commit f62c7cc)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit to vstinner/cpython that referenced this issue Nov 4, 2023
Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.

Fix also StreamTests.tearDown(): the loop must not be closed
explicitly, but using set_event_loop() which takes care of shutting
down the executor with executor.shutdown(wait=True).
BaseEventLoop.close() calls executor.shutdown(wait=False).
vstinner added a commit that referenced this issue Nov 4, 2023
gh-111644: Fix support threading_cleanup() (GH-111714)

Copy the list of dangling threads to make sure that the list of
"Dangling thread" is complete. Previously, the list was incomplete if
threads completed just before the list was displayed.

Changes:

* Rewrite the warning to make it easier to understand.
* Use support.sleeping_retry().
* threading_cleanup() no longer copies threading._dangling,
  but only counts the number of dangling thread.
* Remove support.gc_support() call.
(cherry picked from commit f62c7cc)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this issue Nov 4, 2023
Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.

Fix also StreamTests.tearDown(): the loop must not be closed
explicitly, but using set_event_loop() which takes care of shutting
down the executor with executor.shutdown(wait=True).
BaseEventLoop.close() calls executor.shutdown(wait=False).
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 4, 2023
…1713)

Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.

Fix also StreamTests.tearDown(): the loop must not be closed
explicitly, but using set_event_loop() which takes care of shutting
down the executor with executor.shutdown(wait=True).
BaseEventLoop.close() calls executor.shutdown(wait=False).
(cherry picked from commit ac01e22)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit to miss-islington/cpython that referenced this issue Nov 4, 2023
Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.

Fix also StreamTests.tearDown(): the loop must not be closed
explicitly, but using set_event_loop() which takes care of shutting
down the executor with executor.shutdown(wait=True).
BaseEventLoop.close() calls executor.shutdown(wait=False).

(cherry picked from commit ac01e22)
vstinner added a commit that referenced this issue Nov 4, 2023
gh-111644: Fix support threading_cleanup() (GH-111714)

Copy the list of dangling threads to make sure that the list of
"Dangling thread" is complete. Previously, the list was incomplete if
threads completed just before the list was displayed.

Changes:

* Rewrite the warning to make it easier to understand.
* Use support.sleeping_retry().
* threading_cleanup() no longer copies threading._dangling,
  but only counts the number of dangling thread.
* Remove support.gc_support() call.
(cherry picked from commit f62c7cc)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this issue Nov 4, 2023
…n client_connected_cb (GH-111601) (GH-111632) (#111634)

* [3.12] GH-110894: Call loop exception handler for exceptions in client_connected_cb (GH-111601) (GH-111632)
(cherry picked from commit 9aa8829)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Call loop exception handler for exceptions in `client_connected_cb` of `asyncio.start_server` so that applications can handle it..
(cherry picked from commit 229f44d)

* gh-111644: Fix asyncio test_unhandled_exceptions() (#111713)

Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.

Fix also StreamTests.tearDown(): the loop must not be closed
explicitly, but using set_event_loop() which takes care of shutting
down the executor with executor.shutdown(wait=True).
BaseEventLoop.close() calls executor.shutdown(wait=False).

(cherry picked from commit ac01e22)

---------

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
@kumaraditya303
Copy link
Contributor

Thanks @vstinner

vstinner added a commit that referenced this issue Nov 4, 2023
…#111718)

gh-111644: Fix asyncio test_unhandled_exceptions() (GH-111713)

Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.

Fix also StreamTests.tearDown(): the loop must not be closed
explicitly, but using set_event_loop() which takes care of shutting
down the executor with executor.shutdown(wait=True).
BaseEventLoop.close() calls executor.shutdown(wait=False).
(cherry picked from commit ac01e22)

Co-authored-by: Victor Stinner <vstinner@python.org>
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Copy the list of dangling threads to make sure that the list of
"Dangling thread" is complete. Previously, the list was incomplete if
threads completed just before the list was displayed.

Changes:

* Rewrite the warning to make it easier to understand.
* Use support.sleeping_retry().
* threading_cleanup() no longer copies threading._dangling,
  but only counts the number of dangling thread.
* Remove support.gc_support() call.
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Fix test_unhandled_exceptions() of test_asyncio.test_streams: break
explicitly a reference cycle.

Fix also StreamTests.tearDown(): the loop must not be closed
explicitly, but using set_event_loop() which takes care of shutting
down the executor with executor.shutdown(wait=True).
BaseEventLoop.close() calls executor.shutdown(wait=False).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-asyncio
Projects
Status: Done
Development

No branches or pull requests

3 participants