temporalio / temporalio/samples-python
[Bug] RestrictedWorkflowAccessError on async context manager in return close of an activity.
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 367
- 派生
- 121
- 平均合并
- 3 天 20 小时
- 30 天内合并 PR
- 11
描述
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
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 temporal==1.10.0 和 httpx.AsyncClient 重现 issue 中的最小 activity 示例,然后调查 workflow sandbox 限制是否会在异步上下文管理器的 aexit 期间重新启用。完成标准是 activity 可以返回 HTTP 响应而不会引发 RestrictedWorkflowAccessError。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100