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
| Name | Type | Description |
|---|---|---|
running | str | |
wanted | str |
Attributes
| Name |
|---|
code |
Jobs
class Jobs()The slot of the background work.
SourceAttributes
| Name | Type |
|---|---|
kind | Optional[str] |
check
def check(kind: str) -> None:Raise Busy when the slot is taken.
Parameters
| Name | Type | Description |
|---|---|---|
kind | str |
running
def running(kind: Optional[str] = None) -> bool:Whether a job runs; of this kind only, when given.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
kind | Optional[str] | None |
start
def start(kind: str, work: Coroutine[Any, Any, None]) -> None:Run a job in the background.
Parameters
| Name | Type | Description |
|---|---|---|
kind | str | |
work | Coroutine[Any, Any, None] |
Raises
BusyAnother job runs; the work is not started.
waitasync
async def wait() -> None:Wait for the running job, if any (for the tests).
SourceAttributes
| Name | Value |
|---|---|
RENAME | 'rename' |
SCAN | 'scan' |