You've already forked FrameTour-RenderWorker
- 将 RENDER_SEGMENT_VIDEO 和 PACKAGE_SEGMENT_TS 任务类型合并为 RENDER_SEGMENT_TS - 移除独立的 PackageSegmentTsHandler,将其功能集成到 RenderSegmentTsHandler 中 - 更新任务执行器中的 GPU 资源分配配置 - 修改单元测试以适配新的任务类型名称 - 在 TaskType 枚举中保留历史任务类型的兼容性标记 - 更新常量定义和默认功能配置中的任务类型引用 - 添加视频精确裁剪和 TS 封装功能到渲染处理器中
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import importlib
|
|
from types import SimpleNamespace
|
|
|
|
import util.tracing as tracing_module
|
|
|
|
|
|
def _create_task_stub():
|
|
task_type = SimpleNamespace(value="RENDER_SEGMENT_TS")
|
|
return SimpleNamespace(
|
|
task_id="task-1001",
|
|
task_type=task_type,
|
|
get_job_id=lambda: "job-2002",
|
|
get_segment_id=lambda: "seg-3003",
|
|
)
|
|
|
|
|
|
def test_task_trace_scope_sets_and_resets_context(monkeypatch):
|
|
monkeypatch.setenv("OTEL_ENABLED", "false")
|
|
tracing = importlib.reload(tracing_module)
|
|
|
|
assert tracing.initialize_tracing("worker-1", "2.0.0") is False
|
|
assert tracing.get_current_task_context() is None
|
|
|
|
with tracing.task_trace_scope(_create_task_stub()) as span:
|
|
assert span is None
|
|
context = tracing.get_current_task_context()
|
|
assert context is not None
|
|
assert context.task_id == "task-1001"
|
|
assert context.task_type == "RENDER_SEGMENT_TS"
|
|
assert context.job_id == "job-2002"
|
|
assert context.segment_id == "seg-3003"
|
|
|
|
with tracing.start_span("render.task.sample.step") as child_span:
|
|
assert child_span is None
|
|
|
|
assert tracing.get_current_task_context() is None
|
|
|
|
|
|
def test_bind_trace_context_restores_previous_context(monkeypatch):
|
|
monkeypatch.setenv("OTEL_ENABLED", "false")
|
|
tracing = importlib.reload(tracing_module)
|
|
|
|
tracing.initialize_tracing("worker-1", "2.0.0")
|
|
context = tracing.TaskTraceContext(task_id="task-1", task_type="FINALIZE_MP4")
|
|
|
|
assert tracing.get_current_task_context() is None
|
|
with tracing.bind_trace_context(None, context):
|
|
assert tracing.get_current_task_context() == context
|
|
assert tracing.get_current_task_context() is None
|