sleep

Sleep is not working on pyqt4

我的未来我决定 提交于 2019-11-30 09:04:27
问题 I have got this problem. I´m trying to set text on a lineEdit object on pyqt4, then wait for a few seconds and changing the text of the same lineEdit. For this I´m using the time.sleep() function given on the python Time module. But my problem is that instead of setting the text, then waiting and finally rewrite the text on the lineEdit, it just waits the time it´s supposed to sleep and only shows the final text. My code is as follows: from PyQt4 import QtGui from gui import * class Ventana

nanosleep high cpu usage?

谁说我不能喝 提交于 2019-11-30 07:34:34
I noticed that a little test program which calls nanosleep is showing a huge difference in CPU usage when run on Linux machines with a kernel newer than 2.6.22. #include <time.h> int main (void) { struct timespec sleepTime; struct timespec returnTime; sleepTime.tv_sec = 0; sleepTime.tv_nsec = 1000; while (1) { nanosleep(&sleepTime, &returnTime); } return 0; } (Yes, I realise this program does nothing) If I compile this and run it on an openSUSE 10.3 machine (2.6.22.19-0.2-default), the program does not even show up on the process list generated by "top", indicating to me that it is using very

Display a countdown for the python sleep function

拥有回忆 提交于 2019-11-30 06:51:27
I am using time.sleep(10) in my program. Can display the countdown in the shell when I run my program? >>>run_my_program() tasks done, now sleeping for 10 seconds and then I want it to do 10,9,8,7.... is this possible? aestrivex you could always do #do some stuff print 'tasks done, now sleeping for 10 seconds' for i in xrange(10,0,-1): time.sleep(1) print i This snippet has the slightly annoying feature that each number gets printed out on a newline. To avoid this, you can import sys import time for i in xrange(10,0,-1): sys.stdout.write(str(i)+' ') sys.stdout.flush() time.sleep(1) Saullo G. P

Python & Selenium: Difference between driver.implicitly_wait() and time.sleep()

痞子三分冷 提交于 2019-11-30 06:05:21
问题 Yes, I know both are used to wait for some specified time. Selenium: driver.implicitly_wait(10) Python: import time time.sleep(10) Is there any difference between these two? 回答1: time.sleep(secs) time.sleep(secs) suspends the execution of the current thread for the given number of seconds. The argument may be a floating point number to indicate a more precise sleep time. The actual suspension time may be less than that requested because any caught signal will terminate the sleep() following

Tell Ruby Program to Wait some amount of time

眉间皱痕 提交于 2019-11-30 05:53:57
问题 How do you tell a Ruby program to wait an arbitrary amount of time before moving on to the next line of code? 回答1: Like this: sleep(num_secs) The num_secs value can be an integer or float. Also, if you're writing this within a Rails app, or have included the ActiveSupport library in your project, you can construct longer intervals using the following convenience syntax: sleep(4.minutes) # or, even longer... sleep(2.hours); sleep(3.days) # etc., etc. # or shorter sleep(0.5) # half a second 回答2

Adding a delay without Thread.sleep and a while loop doing nothing

荒凉一梦 提交于 2019-11-30 05:08:57
问题 I need to add delay without using Thread.sleep() or a while loop doing nothing. The game im editing(Minecraft) clock runs on "Ticks" but they can fluctuate depending on your FPS. public void onTick() {//Called every "Tick" if(variable){ //If my variable is true boolean = true; //Setting my boolean to true /** *Doing a bunch of things. **/ //I need a delay for about one second here. boolean = false; //Setting my boolean to false; } } The reason why i need a delay is because if i dont have one

Thread.sleep() is hung?

若如初见. 提交于 2019-11-30 04:45:47
Here's my simple code to loop every second (doesn't need to be exact) and kick off a job if necessary: while (true) { // check db for new jobs and // kick off thread if necessary try { Thread.sleep(1000); } catch(Throwable t) { LOG.error("", t); } } This code has worked fine for several months. Just yesterday we started having problems where one of our servers seems to be hung in the Thread.sleep(1000) method . IOW - it's been over a day and the Thread.sleep hasn't returned. I started up jconsole and get this info about the thread. Name: Thread-3 State: TIMED_WAITING Total blocked: 2 Total

Pthread - What is the difference between time.h::sleep() and pthread.h::pthread_yield()?

柔情痞子 提交于 2019-11-30 03:39:46
I spent a good long while looking for info on the differences between time.h::sleep() and pthread.h::pthread_yield() but was unable to find any solid reference material and so I am posting this question. What is the difference between time.h::sleep() and pthread.h::pthread_yield()? Update: The reason I ask is because I was using sleep() to sleep() each individual thread... and my application started having issues when there was 8 threads vs 4 threads. When I went online to see if sleep() only affects each thread, I couldn't find any good reference stating whether Sleep() affects the entire

How to reveal that screen is locked?

穿精又带淫゛_ 提交于 2019-11-30 02:24:10
In my application I need to know when device is locked (on HTC's it looks like short press on "power" button). So the question is: which event is triggered when device is locked? Or device is going to sleep? You should extend BroadcastReceiver and implement onReceive , like this: public class YourBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_SCREEN_OFF.equalsIgnoreCase(intent.getAction())) { //screen has been switched off! } } } Then you just have to register it and you'll start receiving events when the screen

Is there a way to wake a sleeping thread?

自古美人都是妖i 提交于 2019-11-30 01:27:12
问题 Is there a way to wake a sleeping thread in C#? So, have it sleep for either a long time and wake it when you want work processed? 回答1: An AutoResetEvent object (or another WaitHandle implementation) can be used to sleep until a signal from another thread is received: // launch a calculation thread var waitHandle = new AutoResetEvent(false); int result; var calculationThread = new Thread( delegate { // this code will run on the calculation thread result = FactorSomeLargeNumber(); waitHandle