Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
2answers
406 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 ...
0
votes
0answers
55 views

PHP secure session handling

So a couple of days ago I decided to make a library for secure PHP session management because it is complicated. There's some documentation on github. Two notable things it does is: Creates a "...
1
vote
1answer
647 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
136 views

Promise-based fixed delay poller with timeout

I have the following functions for polling some function periodically with a timeout ...
2
votes
0answers
47 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 ...
2
votes
2answers
77 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
130 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. ...
5
votes
2answers
424 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
192 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
644 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. ...
4
votes
2answers
695 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 ...
3
votes
1answer
90 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
1k 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 ...
1
vote
1answer
58 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
289 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
857 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
120 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
1k 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
14k 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
970 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
220 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
54k 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
100 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
7k 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
4k 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
14k 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
560 views
19
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 ...