chore: 迁移服务器前同步本地修改
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
- ``request_id`` / ``trace_id`` 默认空、bind 后可读、reset 后还原
|
||||
- ``request_id_scope`` / ``trace_id_scope`` 上下文管理器
|
||||
- ``snapshot`` / ``apply_snapshot`` 跨边界透传
|
||||
- ``snapshot`` 快照当前上下文的 ID
|
||||
- logger 切面:``contextvars`` 中的值会自动写入 ``record["extra"]``
|
||||
"""
|
||||
|
||||
@@ -62,21 +62,6 @@ def test_snapshot_returns_current_ids():
|
||||
assert snap == {"request_id": "r1", "trace_id": "t1"}
|
||||
|
||||
|
||||
def test_apply_snapshot_restores_after_exit():
|
||||
snap = {"request_id": "r2", "trace_id": "t2"}
|
||||
with rc.apply_snapshot(snap):
|
||||
assert rc.get_request_id() == "r2"
|
||||
assert rc.get_trace_id() == "t2"
|
||||
assert rc.get_request_id() == ""
|
||||
assert rc.get_trace_id() == ""
|
||||
|
||||
|
||||
def test_apply_snapshot_handles_none():
|
||||
"""传 None 应是 no-op,不报错。"""
|
||||
with rc.apply_snapshot(None):
|
||||
assert rc.get_request_id() == ""
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_contextvars_isolated_between_concurrent_tasks():
|
||||
"""两个并发的 asyncio task 各自的 trace_id 不应互相串味。"""
|
||||
|
||||
Reference in New Issue
Block a user