cleanup_failed_atomic_write (utils/atomic_write.py)

gitingest_bytedance_deer-flow · backend/packages/harness/deerflow/utils/atomic_write.py · python · MIT
files, tag:knn-classified

Atomic byte publication with normal file-creation permissions.

# Source: https://github.com/bytedance/deer-flow | License: MIT | Copyright 2025 Bytedance Ltd. and/or its affiliates
# Provided via justclaw.it.com; keep this notice with the code.
"""Atomic byte publication with normal file-creation permissions."""

from __future__ import annotations

import logging
import os
import stat
from contextlib import suppress
from pathlib import Path
from uuid import uuid4

logger = logging.getLogger(__name__)


def cleanup_failed_atomic_write(temporary: Path, fd: int | None = None) -> None:
    """Release an owned temporary without replacing the caller's outcome.

    Pass *fd* only while the raw descriptor is still owned by the caller;
    successful ``fdopen`` transfers that ownership to the file object.
    An explicitly transferred duplicate descriptor is 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key