python - 收到消息后立即发送 201 响应,然后将其保存到 DB - Python 3.6
问题描述
我们有一个从设备接收数据的 python (3.6) 脚本。
我们需要在收到消息后立即发送 201 响应,然后再将其保存到 DB。
如何执行返回 201 并保持脚本运行?
def main(args):
'''
Main function - runs every time the function is executed.
'''
print("HELLO")
## need to send a return 201 right now and continue running the
## code to save data into DB
...
args = {"temp1":{"timestamp": posix_dt, "value": store_details['value']}}
req = update_device(device, args, token)
return {"status": "Ok", "result": req.json()}
## saved to DB
非常感谢您的帮助。最好的,
解决方案
推荐阅读
- c++ - 显示 3D 三角形的旋转
- python - 如何在 Numpy 中重复行并保持顺序?
- sql - 以下 SQL 查询中何时计算 NULL
- javascript - lint-staged 添加了命令路径
- r - 独立排列列
- powershell - Powershell 启动进程 pnputil.exe
- java - 如何使用spring boot访问属性@value
- powershell - 无法从 webscrape Powershell 获取 href 链接
- csv - 避免在缓冲读取中拆分 CSV 记录?
- flutter - Flutter - Inkwell 与 FlatButton 作为孩子的涟漪不起作用