Skip to content

bpo-40115: Fix refleak in test_asyncio#19282

Merged
vstinner merged 1 commit intopython:masterfrom
aeros:bpo40115-test_asyncio-run_in_executor_cancel
Apr 2, 2020
Merged

bpo-40115: Fix refleak in test_asyncio#19282
vstinner merged 1 commit intopython:masterfrom
aeros:bpo40115-test_asyncio-run_in_executor_cancel

Conversation

@aeros
Copy link
Contributor

@aeros aeros commented Apr 1, 2020

My change to remove daemon threads in concurrent.futures (#19149) revealed a subtle issue in test_events.test_run_in_executor_cancel: it does not properly clean up the executor's resources. This should be done by calling loop.shutdown_default_executor() prior to loop.close(), as is done in asyncio.run().

Before:

[aeros:~/repos/aeros-cpython]$ ./python -m test --fail-env-changed -R 3:3 test_asyncio -m test.test_asyncio.test_events.EPollEventLoopTests.test_run_in_executor_cancel
0:00:00 load avg: 0.63 Run tests sequentially
0:00:00 load avg: 0.63 [1/1] test_asyncio
beginning 6 repetitions
123456
......
test_asyncio leaked [1, 1, 1] references, sum=3
test_asyncio leaked [2, 1, 1] memory blocks, sum=4
test_asyncio failed

== Tests result: FAILURE ==

1 test failed:
    test_asyncio

Total duration: 3.2 sec
Tests result: FAILURE

After:

[aeros:~/repos/aeros-cpython]$ ./python -m test --fail-env-changed -R 3:3 test_asyncio -m test.test_asyncio.test_events.EPollEventLoopTests.test_run_in_executor_cancel
0:00:00 load avg: 0.24 Run tests sequentially
0:00:00 load avg: 0.24 [1/1] test_asyncio
beginning 6 repetitions
123456
......

== Tests result: SUCCESS ==

1 test OK.

Total duration: 3.5 sec
Tests result: SUCCESS

/cc @vstinner @pitrou @1st1

https://bugs.python.org/issue40115

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir topic-asyncio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants