Skip to content

Commit 85726bc

Browse files
python: address telemetry review nits
- Use asyncio.create_task instead of the legacy asyncio.ensure_future when scheduling awaitable notification handlers on the event loop thread. - Drop the redundant local `import asyncio` in the telemetry transport test (asyncio is already imported at module scope), clearing CodeQL py/repeated-import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent da54ca3 commit 85726bc

2 files changed

Lines changed: 1 addition & 3 deletions

File tree

python/copilot/_jsonrpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ async def _await_outcome():
463463
except Exception: # pylint: disable=broad-except
464464
logger.warning("Notification handler raised", exc_info=True)
465465

466-
asyncio.ensure_future(_await_outcome())
466+
asyncio.create_task(_await_outcome())
467467

468468
async def _dispatch_request(self, message: dict, handler: RequestHandler):
469469
try:

python/test_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,8 +2342,6 @@ async def mock_request(method, params, **kwargs):
23422342

23432343
@pytest.mark.asyncio
23442344
async def test_event_routes_to_handler_via_notification_transport(self):
2345-
import asyncio
2346-
23472345
from copilot.generated.rpc import GitHubTelemetryNotification
23482346

23492347
received: list = []

0 commit comments

Comments
 (0)