Provides a dedicated thread pool executor to offload blocking filesystem operations into async coroutines, preventing event loop blocking.
# 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.
"""Dedicated async offload helper for filesystem work."""
from __future__ import annotations
import asyncio
import atexit
import contextvars
import functools
import logging
import os
import threading
from collections.abc import Callable, Coroutine
from concurrent.futures import ThreadPoolExecutor
from typing import Any
logger = logging.getLogger(__name__)
def _default_file_io_workers() -> int:
raw = os.getenv("DEER_FLOW_FILE_IO_WORKERS")
if raw:
try:
workers = int(raw)
if workers > 0:
return workers
except ValueError:
pass
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key