This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_asyncio: test_sock_client_fail() changes asyncio.events._event_loop_policy
Type: Stage: resolved
Components: asyncio, Tests Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, gvanrossum, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2022-02-10 11:53 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31253 merged asvetlov, 2022-02-10 12:36
PR 31255 merged asvetlov, 2022-02-10 12:59
PR 31256 merged asvetlov, 2022-02-10 13:03
Messages (5)
msg412991 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-10 11:53
Seen on s390x RHEL7 Refleaks 3.x:
https://buildbot.python.org/all/#/builders/129/builds/300

== Tests result: FAILURE ==
(...)
3 tests failed:
    test_asyncio test_importlib test_unittest
(...)
0:36:44 load avg: 0.50 Re-running test_asyncio in verbose mode (matching: test_sock_client_fail)
beginning 6 repetitions
123456
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.EPollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.PollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.SelectEventLoopTests) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.062s

OK
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.EPollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.PollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.SelectEventLoopTests) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.061s

OK
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.EPollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.PollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.SelectEventLoopTests) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.055s

OK
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.EPollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.PollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.SelectEventLoopTests) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.053s

OK
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.EPollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.PollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.SelectEventLoopTests) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.060s

OK
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.EPollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.PollEventLoopTests) ... ok
test_sock_client_fail (test.test_asyncio.test_sock_lowlevel.SelectEventLoopTests) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.060s

OK
......
Warning -- asyncio.events._event_loop_policy was modified by test_asyncio
Warning --   Before: None
Warning --   After:  <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x3ff9cac3f80>
msg412992 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-10 11:55
By default, asyncio.events._event_loop_policy is None:

$ ./python -i
>>> import asyncio; asyncio.events._event_loop_policy is None
True


After running the test, it changes:

vstinner@apu$ ./python -i
Python 3.11.0a5+ (heads/main:46328d8ae6, Feb  9 2022, 21:25:58) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio; asyncio.events._event_loop_policy is None
True
>>> 
vstinner@apu$ ./python -i -m test test_asyncio -m test_sock_client_fail
(...)
Tests result: SUCCESS
(...)
SystemExit: 0
>>> import asyncio; asyncio.events._event_loop_policy
<asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7ff7286e7530>
msg412994 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-02-10 12:24
Thanks for the report!
Let me make a fix PR in a few minutes
msg412999 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-10 13:29
With PR 31253 fix, I confirm that it fix my bug explained in msg412992.

commit 012e77eb5c3ba3d411f5967a7f368ebdb42ab88c
Author: Andrew Svetlov <andrew.svetlov@gmail.com>
Date:   Thu Feb 10 14:57:20 2022 +0200

    Fix warning: asyncio.events._event_loop_policy was modified by test_asyncio (GH-31253)
msg413103 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2022-02-11 22:19
Heh, I just ran into this for test_taskgroups as well. (Alas, I had debugged and fixed it independently before I found this. :-)
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 90864
2022-02-11 22:19:34gvanrossumsetnosy: + gvanrossum
messages: + msg413103
2022-02-10 13:32:35asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-02-10 13:29:11vstinnersetmessages: + msg412999
2022-02-10 13:22:07asvetlovsetversions: + Python 3.9, Python 3.10
2022-02-10 13:03:34asvetlovsetpull_requests: + pull_request29424
2022-02-10 12:59:17asvetlovsetpull_requests: + pull_request29423
2022-02-10 12:36:27asvetlovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29421
2022-02-10 12:24:04asvetlovsetmessages: + msg412994
2022-02-10 11:55:12vstinnersetmessages: + msg412992
2022-02-10 11:53:56vstinnercreate