Initial commit of source - working, but needs stubs for Cocoa

This commit is contained in:
Danielle McLean 2023-11-27 15:49:33 +11:00
parent 1e7fd270eb
commit a673f2ef90
Signed by: 00dani
GPG key ID: 52C059C3B22A753E
12 changed files with 1339 additions and 0 deletions

View 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)