Dolamite Jenkins
asked on
Problem on wake of windows os
I have a problem the persist when my program sits idle (windows os) and it might be important in the compiled form , when it sits idle for a long time ... when you enter information it sometime throws and attribute error for one of the widgets the collects data ... the code works perfect otherwise ... so here is my thought what if I ran a thread that woke up the system every so often say every 10 minutes ? so my question is is there a wake up the computer command ? if not then what is the best way to accomplish this ?
ASKER
I have disabled the hibernation / stand by and it has done it but not as frequently ... I have been searching for the cause for months and Im assuming its some conflict between windows and wxpthon or a glitch in my programming that I cant detect ... I've been running the error tracing code you shared with me and nothing comes up ...
I see :-(
That's bad.
Did you try to upgrade or downgrade your python / wxPython versions???
If disabling hibernation / standby doesn't work, then I'm not sure, whether SetThreadExecutionState()
will change anything.
You could still try it.
Not sure, whether I asked this already : Did you look whether you see anything suspicious in the windows event logs?
Just start evenvvwr from a cmd prompt
and walk through the Windows Logs Perhaps some weird message rings a bell.
That's bad.
Did you try to upgrade or downgrade your python / wxPython versions???
If disabling hibernation / standby doesn't work, then I'm not sure, whether SetThreadExecutionState()
will change anything.
You could still try it.
Not sure, whether I asked this already : Did you look whether you see anything suspicious in the windows event logs?
Just start evenvvwr from a cmd prompt
and walk through the Windows Logs Perhaps some weird message rings a bell.
ASKER
no I didn't try that.... i will check it and let you know what I find
ASKER
I double checked and the problem is only when we come out of hibernate or stand by... when we turn it off we haven't had any problems
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this is the tread i wrote and Im not sure it works
I found this code but I keep getting an error and I thing it's too complicated for my simple program
I know you havent worked with this code but does anything look suspicious with my code ?
import os
import sys
import signal
import threading
import ctypes
import win32api
import time
class WindowsNoSleep(threading.Thread):
def Run(self):
time.sleep(5)
SetThreadExecutionState(ctypes.c_int(ES_DISPLAY_REQUIRED|ES_CONTINUOUS|ES_SYSTEM_REQUIRED))
print SetThreadExecutionState(ctypes.c_int(ES_DISPLAY_REQUIRED|ES_CONTINUOUS|ES_SYSTEM_REQUIRED))
WindowsNoSleep().start()
I found this code but I keep getting an error and I thing it's too complicated for my simple program
Traceback (most recent call last):
File "C:\Python26\sign\windowsnosleep.py", line 38, in <module>
sys.exit(main())
File "C:\Python26\sign\windowsnosleep.py", line 31, in main
kernel32.SetThreadExecutionState(ctypes.c_int(ES_CONTINUOUS|ES_SYSTEM_REQUIRED))
ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention
I know you havent worked with this code but does anything look suspicious with my code ?
import sys
import signal
import threading
import ctypes
import win32api
import time
ES_SYSTEM_REQUIRED = 0x00000001
ES_CONTINUOUS = 0x80000000
event = threading.Event()
def ctrlc(signum, frame) :
event.set()
def main():
'''
Prevent system suspend when idle
'''
signal.signal(signal.SIGINT, ctrlc)
kernel32 = ctypes.CDLL('kernel32.dll')
print kernel32
time.sleep(500)
kernel32.SetThreadExecutionState(ctypes.c_int(ES_CONTINUOUS|ES_SYSTEM_REQUIRED))
event.wait()
print 'Bye!'
return 0
if __name__ == '__main__' :
sys.exit(main())
ASKER
thanks
Is it working?
If not just reply here and I will post the correct call as soon as I had time to try it.
If not just reply here and I will post the correct call as soon as I had time to try it.
to work a round an unknown problem.
In order to identify the root cause:
- does the problem occur only after your system enetered standby mode or hybernate mode or does it
even occur after a certain time (with standby / hibernate disabled)
- try to write the smalles possible program still reproducing above behaviour.
If what you want to do is to avoid / standby / hibernate while your program is active, then on windows the call
SetThreadExecutionState() might be what you are looking for.
I never used this call myself, though I intend to play with in in the next weeks for one of my projects.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa373208%28v=vs.85%29.aspx