Function Time Limit

nend

  • We-Gen
  • When is a theme, no longer what it was when installed?
  • Posts: 163
Function Time Limit
« on May 29th, 2012, 06:11 AM »
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

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,597
Re: Function Time Limit
« Reply #1 on May 29th, 2012, 11:04 AM »
No, there isn't.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


nend

  • We-Gen
  • When is a theme, no longer what it was when installed?
  • Posts: 163
Re: Function Time Limit
« Reply #2 on June 3rd, 2012, 04:19 AM »
That is sad, :sob:, you would think there would be a way to do this by now.

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,597
Re: Function Time Limit
« Reply #3 on June 3rd, 2012, 04:22 AM »
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!
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,893
Re: Function Time Limit
« Reply #4 on June 3rd, 2012, 10:53 PM »
If it makes you feel better... :P
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,597
Re: Function Time Limit
« Reply #5 on June 3rd, 2012, 10:57 PM »
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.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


nend

  • We-Gen
  • When is a theme, no longer what it was when installed?
  • Posts: 163
Re: Function Time Limit
« Reply #6 on June 4th, 2012, 05:04 PM »
The ext is installed on my cheap account. :niark:

Norodo

  • We-Gen
  • Oh you Baidu, so randumb. (60 sites being indexed at once? Jeez)
  • Posts: 390
Re: Function Time Limit
« Reply #7 on June 4th, 2012, 07:05 PM »
Yeah mysqli is pretty much everywhere

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,597
Re: Function Time Limit
« Reply #8 on June 4th, 2012, 07:10 PM »
Hrm, in which case it might be worth making the leap to make use of such extras.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.