Reduce log level for linger task/timer (#83703)

We don't need to warn that loudly for these issues.
This commit is contained in:
Joakim Plate 2022-12-10 12:12:56 +01:00 committed by GitHub
parent d2fc3a22e2
commit c196fefe31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,6 @@ import ssl
import threading import threading
from typing import Any from typing import Any
from unittest.mock import AsyncMock, MagicMock, Mock, patch from unittest.mock import AsyncMock, MagicMock, Mock, patch
import warnings
from aiohttp import client from aiohttp import client
from aiohttp.pytest_plugin import AiohttpClient from aiohttp.pytest_plugin import AiohttpClient
@ -212,14 +211,14 @@ def verify_cleanup(event_loop: asyncio.AbstractEventLoop):
# before moving on to the next test. # before moving on to the next test.
tasks = asyncio.all_tasks(event_loop) - tasks_before tasks = asyncio.all_tasks(event_loop) - tasks_before
for task in tasks: for task in tasks:
warnings.warn(f"Linger task after test {task}") _LOGGER.warning("Linger task after test %r", task)
task.cancel() task.cancel()
if tasks: if tasks:
event_loop.run_until_complete(asyncio.wait(tasks)) event_loop.run_until_complete(asyncio.wait(tasks))
for handle in event_loop._scheduled: # pylint: disable=protected-access for handle in event_loop._scheduled: # pylint: disable=protected-access
if not handle.cancelled(): if not handle.cancelled():
warnings.warn(f"Lingering timer after test {handle}") _LOGGER.warning("Lingering timer after test %r", handle)
handle.cancel() handle.cancel()
# Make sure garbage collect run in same test as allocation # Make sure garbage collect run in same test as allocation