Setting Curl’s Timeout in PHP

See documentation: http://www.php.net/manual/en/function.curl-setopt.php CURLOPT_CONNECTTIMEOUT – The number of seconds to wait while trying to connect. Use 0 to wait indefinitely. CURLOPT_TIMEOUT – The maximum number of seconds to allow cURL functions to execute. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 400); //timeout in seconds also don’t forget to enlarge time execution of php script self: set_time_limit(0);// to … Read more

How to timeout a thread

Indeed rather use ExecutorService instead of Timer, here’s an SSCCE: package com.stackoverflow.q2275443; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; public class Test { public static void main(String[] args) throws Exception { ExecutorService executor = Executors.newSingleThreadExecutor(); Future<String> future = executor.submit(new Task()); try { System.out.println(“Started..”); System.out.println(future.get(3, TimeUnit.SECONDS)); System.out.println(“Finished!”); } catch (TimeoutException e) … Read more

How to set HttpResponse timeout for Android in Java

In my example, two timeouts are set. The connection timeout throws java.net.SocketTimeoutException: Socket is not connected and the socket timeout java.net.SocketTimeoutException: The operation timed out. HttpGet httpGet = new HttpGet(url); HttpParams httpParameters = new BasicHttpParams(); // Set the timeout in milliseconds until a connection is established. // The default value is zero, that means the … Read more

Using module ‘subprocess’ with timeout

In Python 3.3+: from subprocess import STDOUT, check_output output = check_output(cmd, stderr=STDOUT, timeout=seconds) output is a byte string that contains command’s merged stdout, stderr data. check_output raises CalledProcessError on non-zero exit status as specified in the question’s text unlike proc.communicate() method. I’ve removed shell=True because it is often used unnecessarily. You can always add it … Read more

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated

Looks like you have a query that is taking longer than it should. From your stack trace and your code you should be able to determine exactly what query that is. This type of timeout can have three causes; There’s a deadlock somewhere The database’s statistics and/or query plan cache are incorrect The query is … Read more

Timeout on a function call

You may use the signal package if you are running on UNIX: In [1]: import signal # Register an handler for the timeout In [2]: def handler(signum, frame): …: print(“Forever is over!”) …: raise Exception(“end of time”) …: # This function *may* run for an indetermined time… In [3]: def loop_forever(): …: import time …: … Read more

How to sleep for five seconds in a batch file/cmd [duplicate]

I’m very surprised no one has mentioned: C:\> timeout 5 N.B. Please note however (thanks Dan!) that timeout 5 means: Sleep anywhere between 4 and 5 seconds This can be verified empirically by putting the following into a batch file, running it repeatedly and calculating the time differences between the first and second echos: @echo … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)