Function Time Limit

nend

  • When is a theme, no longer what it was when installed?
  • Messages: 165
Function Time Limit
« le 29 Mai 2012 à 06:11 »
I was wondering is there any way in PHP to set a time limit on a PHP function. Say if the function is not done in a certain amount of time the function execution is cancelled and the function returns nothing.

What I want to do is start a heavy query and if the query doesn't finish in a certain amount of time have the query stop and the function exited.

Arantor

  • As powerful as possible, as complex as necessary.
  • Messages: 14 278
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

nend

  • When is a theme, no longer what it was when installed?
  • Messages: 165
Re: Function Time Limit
« Réponse #2, le 3 Juin 2012 à 04:19 »
That is sad, :sob:, you would think there would be a way to do this by now.

Arantor

  • As powerful as possible, as complex as necessary.
  • Messages: 14 278
Re: Function Time Limit
« Réponse #3, le 3 Juin 2012 à 04:22 »
That concept only really works if the setup is properly geared for asynchronous behaviour, something PHP isn't.

That said, the MySQLi driver (note, not the ext/mysql driver that SMF and Wedge rely on) can actually set a timeout with the mysqli_options() function but you can't intermix them.

That might be enough reason to convince us to move to ext/mysqli though!

Nao

  • Dadman with a boy
  • Messages: 16 082

Arantor

  • As powerful as possible, as complex as necessary.
  • Messages: 14 278
Re: Function Time Limit
« Réponse #5, le 3 Juin 2012 à 22:57 »
I said *might*. It's not really a *huge* change from my perspective, MySQLi can be used mostly as a drop-in replacement over MySQL's original driver, but I'm not sure how widely deployed MySQLi is.

nend

  • When is a theme, no longer what it was when installed?
  • Messages: 165
Re: Function Time Limit
« Réponse #6, le 4 Juin 2012 à 17:04 »
The ext is installed on my cheap account. :niark:

Norodo

  • Oh you Baidu, so randumb. (60 sites being indexed at once? Jeez)
  • Messages: 469

Arantor

  • As powerful as possible, as complex as necessary.
  • Messages: 14 278
Re: Function Time Limit
« Réponse #8, le 4 Juin 2012 à 19:10 »
Hrm, in which case it might be worth making the leap to make use of such extras.