12345678910111213141516171819202122 |
- from __future__ import annotations
- import asyncio
- from collections.abc import Coroutine
- from typing import Any, TypeVar
- _R = TypeVar("_R")
- _BACKGROUND_TASKS: set[asyncio.Task[Any]] = set()
- def create_background_task(target: Coroutine[Any, Any, _R]) -> asyncio.Task[_R]:
- """Create a background task."""
- task = asyncio.create_task(target)
- _BACKGROUND_TASKS.add(task)
- task.add_done_callback(_BACKGROUND_TASKS.remove)
- return task
- def celsius_to_fahrenheit(celsius: float) -> float:
- """Convert temperature from Celsius to Fahrenheit."""
- return (celsius * 9 / 5) + 32
|