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

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

Session timeout in ASP.NET

Are you using Forms authentication? Forms authentication uses it own value for timeout (30 min. by default). A forms authentication timeout will send the user to the login page with the session still active. This may look like the behavior your app gives when session times out making it easy to confuse one with the … Read more

How to set time limit on raw_input

The signal.alarm function, on which @jer’s recommended solution is based, is unfortunately Unix-only. If you need a cross-platform or Windows-specific solution, you can base it on threading.Timer instead, using thread.interrupt_main to send a KeyboardInterrupt to the main thread from the timer thread. I.e.: import thread import threading def raw_input_with_timeout(prompt, timeout=30.0): print(prompt, end=’ ‘) timer = … Read more

How to add a Timeout to Console.ReadLine()?

I’m surprised to learn that after 5 years, all of the answers still suffer from one or more of the following problems: A function other than ReadLine is used, causing loss of functionality. (Delete/backspace/up-key for previous input). Function behaves badly when invoked multiple times (spawning multiple threads, many hanging ReadLine’s, or otherwise unexpected behavior). Function … 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