问题
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