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 ?
dolamitejenkinsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gelonidaCommented:
My very first impression is, that solving the root cause might be better than trying to 'fake'  activity in order
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

0
dolamitejenkinsAuthor Commented:
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 ...
0
gelonidaCommented:
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.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

dolamitejenkinsAuthor Commented:
no I didn't try that.... i will check it and let you know what I find
0
dolamitejenkinsAuthor Commented:
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
0
gelonidaCommented:
Then avoiding hibernate / standby seems an option.
calling every few minutes SetThreadExecutionState()
should probably do the job.

However I can't tell you the exact parameters as I never used this command myself
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dolamitejenkinsAuthor Commented:
this is the tread i wrote and Im not sure it works


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() 

Open in new window


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

Open in new window


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())  

Open in new window

             
0
dolamitejenkinsAuthor Commented:
thanks
0
gelonidaCommented:
Is it working?
If not just reply here and I will post the correct call as soon as I had time to try it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.