Skip to content

sok.server.jobs

The background work of S.O.K Server: one analysis or one rename at a time.

An analysis must not sort files that a rename is moving, and a rename must not move files an analysis is sorting: they share one slot.

Busy

class Busy(running: str, wanted: str)

Bases: Exception

The slot is taken: already_running for a job of the same kind, else scan_running or rename_running.

Parameters

NameTypeDescription
runningstr
wantedstr
Source

Attributes

Name
code

Jobs

class Jobs()

The slot of the background work.

Source

Attributes

NameType
kindOptional[str]

check

def check(kind: str) -> None:

Raise Busy when the slot is taken.

Parameters

NameTypeDescription
kindstr
Source

running

def running(kind: Optional[str] = None) -> bool:

Whether a job runs; of this kind only, when given.

Parameters

NameTypeDefaultDescription
kindOptional[str]None
Source

start

def start(kind: str, work: Coroutine[Any, Any, None]) -> None:

Run a job in the background.

Parameters

NameTypeDescription
kindstr
workCoroutine[Any, Any, None]

Raises

  • BusyAnother job runs; the work is not started.
Source

waitasync

async def wait() -> None:

Wait for the running job, if any (for the tests).

Source

Attributes

NameValue
RENAME'rename'
SCAN'scan'
Built with Kiln