-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-47015: Update test_os from asyncore to asyncio #31876
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
Conversation
ae7f8bb
to
815cc75
Compare
Note to myself: despite
, it creates an IPv6-only listening socket if possible. As a result, not only Now, I'm sorting out what and why leaks all connected sockets (as Address sanitizer reports) failing all non-Windows runners:
|
f106b3a
to
0e19efb
Compare
0e19efb
to
04cd9ee
Compare
04cd9ee
to
df82a87
Compare
df82a87
to
9882daf
Compare
The failure was a combination of client-side blocking wait of a server and a missing asyncio loop policy. Both problems are fixed. |
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be poked with soft cushions! |
Without the grouping, reading code as a prose becomes harder: > Start the server. For a client, create a socket, set it nonblocking, > get a server name that is a name of its listening port, connect to the > server. instead of: > Start the server, its name is a name of its listening port. For > a client, create a socket, set it nonblocking, connect to the server.
@@ -101,6 +95,10 @@ def create_file(filename, content=b'content'): | |||
'on AIX, splice() only accepts sockets') | |||
|
|||
|
|||
def tearDownModule(): | |||
asyncio.set_event_loop_policy(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line that set a loop policy is not present any more, so this cleanup step doesn’t seem to apply anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand a failed pre-policy run correctly, the policy must either be manually set to something before any case is runned or be returned back to None
before the suit exits. I've chosen the first variant, Andrew proposed to switch to the second.
0:04:29 load avg: 3.56 [300/433/1] test_os failed (env changed) -- running: test_asyncio (1 min 10 sec), test_concurrent_futures (1 min 57 sec)
[a bunch of oks and skips follow]
[...]
423 tests OK.
10 slowest tests:
- test_tools: 4 min 44 sec
- test_concurrent_futures: 3 min 30 sec
- test_peg_generator: 2 min 57 sec
- test_multiprocessing_spawn: 2 min 27 sec
- test_gdb: 1 min 51 sec
- test_asyncio: 1 min 50 sec
- test_multiprocessing_forkserver: 1 min 38 sec
- test_multiprocessing_fork: 1 min 22 sec
- test_regrtest: 1 min 12 sec
- test_statistics: 49.1 sec
1 test altered the execution environment:
test_os
9 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_startfile
test_winconsoleio test_winreg test_winsound test_zipfile64
Total duration: 11 min 50 sec
Tests result: ENV CHANGED
make: *** [Makefile:1795: buildbottest] Error 3
Error: Process completed with exit code 2.
LGTM. Let's wait for the buildbots fleet to finish to make sure that everything works smoothly. |
@asvetlov I fixed a forgotten The second runner, ARM64 macOS, failed on
Considering that the failed |
GitHub Ubuntu runner failed with |
I see. Test failures seem unrelated. |
Merged. Thanks! |
PEP 594 – Removing dead batteries from the standard library removes asyncore and asynchat in 3.12 with the following note:
However, the citation misses the tests for
os
. So this PR portstest_os.TestSendfile
as the only class that uses asyncore to create a dummy sendfile server and communicate with it.To simplify the review I broke all changes into a few commits to get readable diffs:
TestCase
toIsolatedAsyncioTestCase
os.sendfile
async-friendly by moving it into a worker thread to not block an event loop of IsolatedAsyncioTestCase. As a result,sendfile_wrapper
that called it is also made asyncby
IsolatedAsyncioTestCase
is counted as a test failure (this commit is actually the last)SendfileTestServer
withasyncio.start_server
. The client side is left mostly untouched becauseos.sendfile
works directly with a low-level socket ignoring asyncio message loop anyway. "Mostly" becauseconnect
is delegated to an event loop to not block the server in the same thread220 ready
. Instead, we use a guarantee thatasyncio.loop.sock_connect
yields only after establishing a connectionSendfileTestServer
with related asyncio importsasyncio.to_thread
maintains its own threading machinery)https://bugs.python.org/issue47015