X Tutup
Skip to content

bpo-39010: Ignore error on cancelled future after end of loop.#20525

Closed
cmeyer wants to merge 1 commit intopython:masterfrom
cmeyer:bpo-39010-fix-logic
Closed

bpo-39010: Ignore error on cancelled future after end of loop.#20525
cmeyer wants to merge 1 commit intopython:masterfrom
cmeyer:bpo-39010-fix-logic

Conversation

@cmeyer
Copy link

@cmeyer cmeyer commented May 30, 2020

Python 3.8+ outputs spurious error messages for any asyncio.run_forever call with pending run_in_executor calls when it finishes. When used in a loop that single steps through asyncio using loop.stop() followed by loop.run_forever(), there are repeated, useless error messages. The spurious error messages cannot be prevented in any way I can find.

This patch prevents these spurious error messages. The proactor and windows event code probably needs broader improvements to manage its state properly at exit. This patch does not deal with the broader issue. This patch is only a stop-gap to make Python 3.8 usable by our users.

The bug is easily reproduced with the following code (Windows only). I could not make a test case which would fail on the error since the exception is handled (and output) in low level code.

import asyncio
loop = asyncio.get_event_loop()
f = loop.run_in_executor(None, lambda: None)
loop.stop()
loop.run_forever()
loop.stop()
loop.run_forever()
loop.stop()
loop.run_forever()

https://bugs.python.org/issue39010

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup