Coverage for src/lilbee/runtime/cancellation.py: 100%

3 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-08-14 11:46 +0000

1"""Task cancellation sentinel shared between core library and TUI. 

2 

3Raised by progress callbacks when the UI signals a long-running 

4background task should abort. Lives in a neutral module so that 

5``lilbee.catalog`` (core) can let it propagate without importing TUI code. 

6""" 

7 

8from __future__ import annotations 

9 

10from typing import Protocol 

11 

12 

13class TaskCancelledError(Exception): 

14 """Raised inside a progress callback to abort a long-running task.""" 

15 

16 

17class CancelSignal(Protocol): 

18 """Anything a long-running run polls to learn it should stop. 

19 

20 Structural so a run driven from another process can be cancelled by a 

21 ``multiprocessing`` event as readily as by a ``threading`` one. 

22 """ 

23 

24 def is_set(self) -> bool: ...