set_time_limit not working on heroku

做~自己de王妃 提交于 2021-02-09 08:36:36

问题


I am using PHP with heroku. I keep on getting a request timeout error due to some database insertions and queries.

I added this line to all my php files in order to avoid this error:

set_time_limit(0);

However, I am still getting this error. Does heroku ignore this command?

I did a simple check to see if the time limit is being changed:

echo 'TIME : '.ini_get('max_execution_time');
set_time_limit(0);
echo 'TIME : '.ini_get('max_execution_time');

It is being changed from 30 (default value) to 0. Despite the change, I am still getting the error.

Also, I would like to add that the php file is being called by ajax.

Furthermore, as far as I know, php is not set to safe mode, so there is no reason why the command should be ignored.

Heroku suggests to use a background job, and as far as I can tell, it forces you if the task takes more than 30 seconds. Has anybody managed without using a background job?

Update: Tried using:

ini_set('max_execution_time', 0);

Still does not want to work


回答1:


If you have to go over the 30s request timeout on Heroku, you'll need to use a background job - there is no way around that (Heroku will just kill the request if it takes longer than 30 seconds). Heroku has some documentation on this.



来源:https://stackoverflow.com/questions/14173898/set-time-limit-not-working-on-heroku

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!