You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行Python脚本结束Twilio active状态Flow时报ExecutionContext无update属性错误

解决Twilio Studio Flow活跃执行终止报错问题

报错'ExecutionContext' object has no attribute 'update'由两个常见原因导致:

  • 构造执行实例操作路径时遗漏了.v1层级,和查询时的路径不匹配,拿到的是不支持update方法的上下文对象
  • 部分旧版本的Twilio Python SDK中,终止Studio Flow执行的方法为delete()而非更新status字段

适配新版SDK的修复代码

补全.v1层级即可解决路径不匹配问题:

executions = client.studio \
            .v1 \
            .flows('FWXXXXXX') \
            .executions \
            .list(limit=20)

for record in executions:
   if record.status == 'active':
       execution = client.studio \
                    .v1 \
                    .flows('FWXXXXXX') \
                    .executions(record.sid) \
                    .update(status='ended')
       print('ending', execution.sid)

适配旧版SDK的修复代码

如果使用的是7.0版本以下的Twilio Python SDK,直接调用delete方法终止执行即可:

executions = client.studio \
            .v1 \
            .flows('FWXXXXXX') \
            .executions \
            .list(limit=20)

for record in executions:
   if record.status == 'active':
       delete_resp = client.studio \
                    .v1 \
                    .flows('FWXXXXXX') \
                    .executions(record.sid) \
                    .delete()
       print(f'ended execution {record.sid}, delete status: {delete_resp}')

你可以执行pip show twilio查看当前安装的SDK版本,优先升级到最新版使用第一种方案即可。

内容的提问来源于stack exchange,提问作者anupamb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 00:18:03