refactor(lab): move execution to Worker and manage replay and transfer lifecycles
This commit is contained in:
@@ -11,9 +11,10 @@ import os
|
||||
import shutil
|
||||
import stat
|
||||
import threading
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable, Iterator
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
GiB = 1024**3
|
||||
MiB = 1024**2
|
||||
@@ -62,12 +63,12 @@ def cache_publication(
|
||||
root: Path,
|
||||
additional_bytes: int | Callable[[], int],
|
||||
*,
|
||||
kind=None,
|
||||
limit=None,
|
||||
reserve=FREE_RESERVE,
|
||||
max_files=10000,
|
||||
error_type=CacheCapacityError,
|
||||
):
|
||||
kind: str | None = None,
|
||||
limit: int | None = None,
|
||||
reserve: int = FREE_RESERVE,
|
||||
max_files: int = 10000,
|
||||
error_type: type[Exception] = CacheCapacityError,
|
||||
) -> Iterator[None]:
|
||||
"""Lock admission through publication. Count temporary bytes already on disk.
|
||||
|
||||
additional_bytes includes only bytes not yet in this root; a file renamed
|
||||
@@ -118,6 +119,6 @@ def cache_publication(
|
||||
os.close(fd)
|
||||
|
||||
|
||||
def require_cache_room(root: Path, additional_bytes=0, **kwargs):
|
||||
def require_cache_room(root: Path, additional_bytes: int = 0, **kwargs: Any) -> None:
|
||||
with cache_publication(root, additional_bytes, **kwargs):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user