Skip to content

API Background tasks

Alexandre 'kidev' Poumaroux edited this page Oct 21, 2026 · 4 revisions

Background tasks

Import from proleak import tasks

Background work that never blocks the game.

Functions

Returns Function
concurrent.futures.Future run_in_thread(fn: Callable, *args, **kwargs) Run fn(*args, **kwargs) on a worker thread; returns a concurrent.futures.Future.
None call_soon_main(fn: Callable, *args) Queue fn(*args) for the game's main thread at the next frame.
concurrent.futures.Future spawn(coro: Coroutine) Run a coroutine on ProLeak's shared asyncio loop; returns a concurrent.futures.Future.

Values

Type Value
asyncio.AbstractEventLoop loop read-only ProLeak's shared asyncio loop, which spawn runs on.

Function documentation

run_in_thread

run_in_thread(fn: Callable, *args, **kwargs) -> concurrent.futures.Future

Run fn(*args, **kwargs) on a worker thread; returns a concurrent.futures.Future.

Pending work is cancelled when the plugin unloads, and running work receives PluginUnloaded. Game objects are not safe here; hand results back with call_soon_main.

call_soon_main

call_soon_main(fn: Callable, *args) -> None

Queue fn(*args) for the game's main thread at the next frame. Safe from any thread.

spawn

spawn(coro: Coroutine) -> concurrent.futures.Future

Run a coroutine on ProLeak's shared asyncio loop; returns a concurrent.futures.Future.

The task is cancelled when the plugin unloads.

Value documentation

loop

loop: asyncio.AbstractEventLoop [read-only]

ProLeak's shared asyncio loop, which spawn runs on. It runs on its own thread.


Previous: API | Next: Camera

Clone this wiki locally