Initial commit of source - working, but needs stubs for Cocoa
This commit is contained in:
parent
1e7fd270eb
commit
a673f2ef90
12 changed files with 1339 additions and 0 deletions
19
src/mpd_now_playable/async_tools.py
Normal file
19
src/mpd_now_playable/async_tools.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import asyncio
|
||||
from collections.abc import Coroutine
|
||||
from contextvars import Context
|
||||
from typing import Optional
|
||||
|
||||
__all__ = ("run_background_task",)
|
||||
|
||||
background_tasks: set[asyncio.Task[None]] = set()
|
||||
|
||||
|
||||
def run_background_task(
|
||||
coro: Coroutine[None, None, None],
|
||||
*,
|
||||
name: Optional[str] = None,
|
||||
context: Optional[Context] = None,
|
||||
) -> None:
|
||||
task = asyncio.create_task(coro, name=name, context=context)
|
||||
background_tasks.add(task)
|
||||
task.add_done_callback(background_tasks.discard)
|
Loading…
Add table
Add a link
Reference in a new issue