[Bug] RestrictedWorkflowAccessError on async context manager in return close of an activity.
还没有人认领这个 Issue。
评估
调研方向
使用 temporal==1.10.0 和 httpx.AsyncClient 重现 issue 中的最小 activity 示例,然后调查 workflow sandbox 限制是否会在异步上下文管理器的 aexit 期间重新启用。完成标准是 activity 可以返回 HTTP 响应而不会引发 RestrictedWorkflowAccessError。
由索引模型根据 Issue 内容生成。
描述
What are you really trying to do?
When using
@register_activity
@activity.defn
async def get_http_response(URL: str) -> dict:
async with httpx.AsyncClient() as client:
return await client.get(url)
Describe the bug
We get the following error:
RestrictedWorkflowAccessError
Cannot access threading.local.mro_entries from inside a workflow. If this is code from a module not used in a workflow or known to only be used deterministically from a workflow, mark the import as pass through.
Minimal Reproduction
I believe the workflow sandbox is reactivated before the asynclient __aexit__ code.
Which leads to Temporal thinking its execution is happening in the workflow scope rather than within the activity one.
Environment/Versions
temporal==1.10.0
Additional context
I'm trying to split it in two calls to make it work:
@register_activity
@activity.defn
async def get_http_response(URL: str) -> dict:
async with httpx.AsyncClient() as client:
response = await client.get(url)
return response
- 主要语言
- Python
- 星标
- 367
- 派生
- 121
- 平均合并
- 3 天 20 小时
- 30 天内合并 PR
- 11
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
temporalio/samples-python 的其他 Issue
-
enhancement
temporalio/samples-python#254 · 1 条评论 · 已指派 1 人 ·
-
enhancement
temporalio/samples-python#253 · 已指派 1 人 ·
-
enhancement
难度 3/5 1-2 天 新手友好度 45/100
temporalio/samples-python#231 · 1 条评论 ·
-
enhancement
难度 3/5 1-2 天 新手友好度 45/100
temporalio/samples-python#191 ·
-
bug
难度 1/5 1 小时以内 新手友好度 48/100
temporalio/samples-python#184 ·
查看 temporalio/samples-python 的全部 Issue
相似的 Issue
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100