php - php api中的异步函数
问题描述
我希望你能帮帮我
我在 azure Web 应用服务中实现了 php 中的 api。
我需要它来执行加载的脚本并且它滞后,然后在调用它的一分钟内返回 500 错误
我需要你编写一个脚本,该脚本会进行大量的 http 调用、计算并最终将结果发送到数据库。脚本(需要 15 分钟到 2 小时)取决于您的输入,代码如下:
public function get() {
$params = http_build_query($this->request['params']);
/* -- start script --
script takes 15 min to 2 hours depending on input $ params
I need the script to finish before the http call dies
*/
$meli = new Meli;
$meli -> data_extractor($params);
/* -- end script -- */
$this->response = array('Response' => ' script has started working');
$this->responseStatus = 200;
}
我遇到的问题是,当我在调用它几分钟后调用 api 时,它在没有完成脚本的情况下返回 500 错误。
解决方案
推荐阅读
- arrays - 如何将数组值存储在 Postman 的环境变量中
- python - 使用 Bokeh 绘图时如何为多个数据集之一添加悬停工具
- java - 用 Java 调试我的字母等级计算器
- ansible - Ansible替换Windows文本文件中的所有出现 - win_lineinfile
- linux - “未能执行命令:权限被拒绝” Ubuntu 18.04.3 LTS
- bluetooth - 无法连接到树莓派上的 BLE 设备(gatttool/bluetoothctl)
- c# - 从 SSIS 中的 excel 文件中读取日期。SSIS 以不同的格式读取日期
- android - Android LayoutParams 未正确更新
- angular - 在页面上显示多个图表时出现问题
- php - php中水印.JPG图像的问题