Questions tagged [timeout]

Code that handles a condition (normally an error condition) triggered when an event fails to occur within a predefined time limit. For discussing inefficient code that takes an unreasonable amount of time to finish, use the [time-limit-exceeded] tag instead.

Filter by
Sorted by
Tagged with
1
vote
1answer
39 views

Promise for request/response with timeout

Below is a piece of code that uses a promise for sending a request to a server, and to wait for an answer. Under normal conditions the server will always respond immediately, But of course you don't ...
0
votes
2answers
454 views

“Spread the Word” CodeChef challenge

I am solving the "Spread the Word" problem on CodeChef: Snackdown 2019 is coming! People have started to spread the word and tell other people about the contest. There are \$N\$ people numbered 1 ...
2
votes
1answer
2k views

Check for timeout in wait() loop

I want to check for a condition in a guarded wait() loop with a user-specified total timeout, similar to how ...
0
votes
1answer
379 views

Promise-based fixed delay poller with timeout

I have the following functions for polling some function periodically with a timeout ...
2
votes
0answers
49 views

Write one string to a socket within 10 seconds or another string if the time is out

I have implemented a method which will send one data to the server if it (Raspberry Pi Pin Input HIGH, in this case) occurs within 10 seconds. If this doesn't happen within 10 seconds then I should ...
3
votes
2answers
280 views

Using await to break long-running processes

I have a Node.js app / Web API that runs on an Azure app service with a single CPU. One of the functions needs to run for a long time, perhaps tens of seconds, while the server should continue to ...
2
votes
1answer
407 views

Long running operation with timeout

I have a long running operation that I need to wait for or timeout. I have working code, but I would like your opinion on improving it. ...
4
votes
2answers
1k views

Implementing timeout of a resource (in this case a database connection)

I am currently having a problem with too many database connections. Therefore, I am trying to implement a database connection timeout. In the code below the changing of value of the shared resource ...
2
votes
2answers
466 views

Hacker rank - Left rotation - PHP code feedback

Here is the problem description - https://www.hackerrank.com/challenges/ctci-array-left-rotation/problem A left rotation operation on an array of size \$n\$ shifts each of the array's elements 1 ...
6
votes
2answers
1k views

Java time-to-live collection

Here's a class I made in java. It's pretty simple, the description of what it does is in the comment. I'd appreciate any feedback. ...
5
votes
2answers
865 views

Hackerrank: Gridland Metro

Problem statement The city of Gridland is represented as an n X m matrix where the rows are numbered from 1 to ...
2
votes
1answer
104 views

Blow the fuse if threshold exceeded

While implementing the Retry & Breaker patterns I decided that the Breaker does more then it should so I extracted two responsibilities into their own classes. Here they are. I stripped out the <...
-2
votes
1answer
2k views

Example of Callback Hell [closed]

I am trying to come up with a minimal example of what is known as callback hell in JavaScript (so this would be a bad code review I guess). This is what I have so far, and I would like it to also run ...
14
votes
1answer
9k views

Python Executer that kills processes after a timeout

Imagine you want to run a bunch of tasks in parallel, but you can't be sure that all of your tasks will eventually terminate or rather decide to eat up all your memory and CPU time. This should be ...
1
vote
1answer
68 views

TLE in APS - Amazing Prime Sequence in Python at Spoj

This series is similar to Fibonacci Series defined as : a[0] = a[1] = 0 and For n > 1, a[n] = a[n - 1] + f(n), where f(n) is ...
2
votes
1answer
426 views

Exponential backoff generator

Exponential backoff in the context of various networking protocols looks something like this: When a collision first occurs, send a “Jamming signal” to prevent further data being sent. ...
3
votes
1answer
1k views

Handling GetTickCount() overflow in timeouts

This is code which must run on XP, so no GetTickCount64, and which should correctly handle the value wrapping around after 49 days. Can it be improved? ...
1
vote
0answers
157 views

Generic Timeout Handler

In a frontend Javascript project I have to implement a generic timeout mechanism for a set of asynchronous tasks that the program needs to perform. These are the conditions: The tasks are functions ...
1
vote
1answer
2k views

Decorating a timeout function

I've picked up the timeout-function below from ActiveState's recipes for Python2 and polished it for python3.4. Is there any leaner, less clunky way to write it? ...
4
votes
2answers
20k views

Async task with timeout

I am calling a service outside of my control. My application must include a time out, so that if the call to the service takes too long, an appropriate time-out message is returned. ...
4
votes
2answers
1k views

Window timeout alert

How can I improve this window timeout alert code? I need to add it to some third-party master page and don't want to add a separate file for it. It must be JS only and IE-8 supported. jsFiddle <...
3
votes
1answer
2k views

Controlling a Windows Service from a WPF app

I have a WPF Control Panel app, where I'm trying to stay close to an MVVM architecture. The control panel (the "the CP") is for a WCF service ("the Scheduler"), hosted in a Windows Service ("the Host")...
7
votes
1answer
2k views

Batch script to start the service in a gap of 10 min

I have created a batch script to start the services in a gap of 10 min. My batch file will start the service on the local system and then will wait for 10 mins and starts the service on another system ...
1
vote
1answer
229 views

Screen timeout/lock script

This is a script I made while having trouble with xautolock and dimming of the screen right before locking it. I would like some tips for making it a bit more robust and to know of any disadvantages ...
8
votes
1answer
3k views

Web service proxy that switches endpoint URLs in the event of a TimeoutException

I am creating a service (FaultTolerantCommunication) that wraps a call to a (web) service. Its responsibility is to switch the endpoint URL in the event of a ...
11
votes
5answers
60k views

Reading from a serial port

I'm receiving data from a serial port in C, using Serial Programming Guide for POSIX Operating Systems as a guide. The data I receive should be always 10 bytes in length but I want to be sure that, ...
1
vote
1answer
105 views

Node.JS HTTP server displaying Google

I'm reading Professional Node.js: Building Javascript Based Scalable Software by Pedro Teixeira and created a web page responding with www.google.de. Could you take a look at my code and let me know ...
11
votes
1answer
8k views

QNetworkReply network reply timeout helper

Since Qt still does not support to set timeouts on QNetworkRequest objects, I wrote this little wrapper class: ...
3
votes
1answer
5k views

JavaScript “recursion” via setTimeout

I understand that because of JavaScript's single-threaded execution, long loops or recursive calls could make the browser unresponsive while they execute. I thought about simulating recursion using <...
14
votes
3answers
17k views

Timing out a method

I have created this extension method that can be used to run a function with a timeout applied to it. Is this a sensible way of doing it? ...
3
votes
1answer
2k views

Time Limit decorator

I have an interface named ICodeRunner, defined like this: ...
7
votes
1answer
561 views

Waiting for game server connection

...
20
votes
3answers
16k views

Determining if a connection has been made to a communications device

I am unsure if my use of Monitor.Wait and Monitor.Pulse is correct. It seems to work alright, but there is a nagging doubt I am ...