timeout

Detecting a timeout for a block of code in PHP

柔情痞子 提交于 2020-01-11 18:53:15
问题 Is there a way you can abort a block of code if it's taking too long in PHP? Perhaps something like: //Set the max time to 2 seconds $time = new TimeOut(2); $time->startTime(); sleep(3) $time->endTime(); if ($time->timeExpired()){ echo 'This function took too long to execute and was aborted.'; } It doesn't have to be exactly like above, but are there any native PHP functions or classes that do something like this? Edit : Ben Lee's answer with pcnt_fork would be the perfect solution except

Detecting a timeout for a block of code in PHP

喜夏-厌秋 提交于 2020-01-11 18:52:29
问题 Is there a way you can abort a block of code if it's taking too long in PHP? Perhaps something like: //Set the max time to 2 seconds $time = new TimeOut(2); $time->startTime(); sleep(3) $time->endTime(); if ($time->timeExpired()){ echo 'This function took too long to execute and was aborted.'; } It doesn't have to be exactly like above, but are there any native PHP functions or classes that do something like this? Edit : Ben Lee's answer with pcnt_fork would be the perfect solution except

Auto kill process and child process of multiprocessing Pool

好久不见. 提交于 2020-01-11 16:26:11
问题 I am using multiprocessing module for parallel processing. Bellow code snippet search the string filename in X location and return the file name where the string found. But in some cases it take long time to search process so i was trying to kill the search process with take more than 300 seconds.For that i used timeout == 300 as given bellow , this kills the search process but it dosent kill the child process spawn by bellow code. I tried to find multiple way but no success :/ How can i kill

Auto kill process and child process of multiprocessing Pool

删除回忆录丶 提交于 2020-01-11 16:26:08
问题 I am using multiprocessing module for parallel processing. Bellow code snippet search the string filename in X location and return the file name where the string found. But in some cases it take long time to search process so i was trying to kill the search process with take more than 300 seconds.For that i used timeout == 300 as given bellow , this kills the search process but it dosent kill the child process spawn by bellow code. I tried to find multiple way but no success :/ How can i kill

How to execute a sequence of events in Angular using $timeout

最后都变了- 提交于 2020-01-11 13:01:11
问题 I have a div in my view , I want to execute a function on ng-click() which turns the background for the div to 'color a' for 30 seconds if there's no action taken then for 60 seconds then change to 'color b' and if no action is taken beyond 120 seconds just hide the div.(this can be done via adding/removing classes as well ) In essence I'm looking to execute a sequence of $timeouts in angular where one timeout leads into another. Any help on that would be hugely appreciated. Thanks. 回答1: I

Perl, make script timeout after x number of seconds?

ぐ巨炮叔叔 提交于 2020-01-11 09:26:27
问题 I have been searching on this but it is surprisingly hard to come by a straight answer to this (as php has a lot more info on this topic it seems).. I need to make my perl script die after a specified number of seconds because, as it is now, they are running too long and clogging up my system, how can I make it so the entire script just dies after a specified number of seconds? I know about external solutions to kill the script but I would like to do it from within the perl script itself.

iPhone SDK: URL request not timing out

眉间皱痕 提交于 2020-01-10 20:01:35
问题 I am having a problem with a network request that should timeout, but the method is not called. The request is as follows: #define kCONNECT_TIMEOUT 20.0 request = [NSMutableURLRequest requestWithURL: aUrl]; [request setHTTPMethod: @"POST"]; postData = [jsonData dataUsingEncoding:NSASCIIStringEncoding]; [request setHTTPBody:postData]; [request setValue:@"text/xml" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setCachePolicy

Add timeout argument to python's Queue.join()

强颜欢笑 提交于 2020-01-10 08:24:46
问题 I want to be able to join() the Queue class but timeouting after some time if the call hasn't returned yet. What is the best way to do it? Is it possible to do it by subclassing queue\using metaclass? 回答1: Subclassing Queue is probably the best way. Something like this should work (untested): def join_with_timeout(self, timeout): self.all_tasks_done.acquire() try: endtime = time() + timeout while self.unfinished_tasks: remaining = endtime - time() if remaining <= 0.0: raise NotFinished self

jdbc4 CommunicationsException

こ雲淡風輕ζ 提交于 2020-01-10 01:40:23
问题 I have a machine running a java app talking to a mysql instance running on the same instance. the app uses jdbc4 drivers from mysql. I keep getting com.mysql.jdbc.exceptions.jdbc4.CommunicationsException at random times. Here is the whole message. Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was25899 milliseconds ago.The last packet sent successfully to the

How to disable or change the timeout limit for the GPU under linux?

孤街浪徒 提交于 2020-01-09 10:23:07
问题 Does anybody know how to disable or change the timeout limit for CUDA kernels under Ubuntu 12.10? (With current versions of Windows one can set the timeout limit in the registry.) Please tell me as well if there is no possibility to do this with Ubuntu. The only results of my previous search are the following: running the CUDA kernel without a graphical display is attached to the GPU splitting the kernel into smaller ones to avoid exceeding the time limit Both solutions are no option for me