time.sleep — sleeps thread or process?

It blocks the thread. If you look in Modules/timemodule.c in the Python source, you’ll see that in the call to floatsleep(), the substantive part of the sleep operation is wrapped in a Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS block, allowing other threads to continue to execute while the current one sleeps. You can also test this with a … Read more

Prevent windows from going into sleep when my program is running?

After considering vim’s answer “Using PowerCreateRequest, PowerSetRequest, and PowerClearRequest functions is the preferred method.” with the linked AvailabilityRequests.docx on msdn which is exhausting to get into it (too much to read), I have searched the web for a concrete example in c# that is based on the PowerCreateRequest and found http://go4answers.webhost4life.com/Example/problem-monitor-wakeup-service-windows7-12092.aspx [EDIT 2016 – isn’t … Read more

Compare using Thread.Sleep and Timer for delayed execution

One difference is that System.Threading.Timer dispatches the callback on a thread pool thread, rather than creating a new thread every time. If you need this to happen more than once during the life of your application, this will save the overhead of creating and destroying a bunch of threads (a process which is very resource … Read more

JavaScript sleep/wait before continuing [duplicate]

JS does not have a sleep function, it has setTimeout() or setInterval() functions. If you can move the code that you need to run after the pause into the setTimeout() callback, you can do something like this: //code before the pause setTimeout(function(){ //do what you need here }, 2000); see example here : http://jsfiddle.net/9LZQp/ This … Read more