Python中文
首页
教程
问答
标签
搜索
登录
注册
如何在气流中通过xcom将参数从PythonOperator传递到HttpSensor?
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我想发送一个HTTP请求,其参数依赖于一个依赖于Python调用的结果。我正尝试使用XComs来实现这个目的。简化示例:</p> <pre><code>def get_index(): return 0 get_index = PythonOperator( task_id='get_index', python_callable=get_index, dag=dag) http_request = HttpSensor( task_id='send_http_request', http_conn_id=HTTP_HOST, endpoint=ENDPOINT, params={ "index": "{{ ti.xcom_pull('get_index') }}" }, dag=dag) get_index >> http_request </code></pre> <p>不幸的是,在检查了HTTP请求的选项之后,我发现宏没有得到正确的计算,而是发送了<code>0</code>,<code>{{ ti.xcom_pull('get_index') }}</code>。可能出了什么问题?我应该使用<code>HttpOperator</code>而不是<code>HttpSensor</code>?在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>正如<a href="https://stackoverflow.com/users/7036929/faeder">faeder</a>所提到的,<code>params</code>中的jinja模板目前没有被评估。我通过切换到<code>SimpleHttpOperatr</code>s并将模板放在<code>data</code>字段中来解决这个问题。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在乒乓球比赛中预测球的轨迹,对于AI球拍预测?
5 回答
如何在乒乓球游戏中阻止球
7 回答
如何在乘法和模中不乘空间?
10 回答
如何在乘法和除以2个不同的数字之间进行交换?
6 回答
如何在也是数据一部分的单个字符上拆分大字符串
7 回答
如何在乾草堆中找到針,有更好的解決方案嗎?
2 回答
如何在事件wxWidgets中传递自定义数据
1 回答
如何在事件中使用lambda i=i?
6 回答
如何在事件中心只接收最近的数据
3 回答
如何在事件发生之前保持云函数运行?
1 回答
如何在事件发生后使页面重定向到同一页面
5 回答
如何在事件回调之间保持python生成器的状态
5 回答
如何在事件处理程序(pythonsocket、sphinx)中保留docstring
2 回答
如何在事件处理程序中更改wxRichTextCtrl的光标位置?
6 回答
如何在事件处理程序中访问外部对象?
10 回答
如何在事件循环中将协程打包为正常函数?
7 回答
如何在事件循环之外运行协同程序?
5 回答
如何在事件循环结束时为并发未来的所有线程调用类方法?
9 回答
如何在事件文件中只保留一份摘要?
3 回答
如何在事件模板中添加事件
1 回答