ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention

I'm trying to use SetThreadExecutionState to not allow windows to hibernate or go idle which reaks havoc with my program which runs for a long period of time with no data being entered but at times is suddenly called to action... I found this code and I want to us it but ... first I don't completely understand ctypes or kernel32.dll ... I keep getting this error  and How would I turn this into a safe thread ?

ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention
File "C:\Python26\sign\", line 40, in <module>
File "C:\Python26\sign\", line 33, in main

Open in new window

I don't understand the error and there is not alot of python information on this topic ... anyone have any ideas ?

import os
import sys
import signal
import threading
import ctypes
import win32api
import time

ES_CONTINUOUS = 0x80000000

event = threading.Event()

def ctrlc(signum, frame) :

def main():
    Prevent system suspend when idle
    signal.signal(signal.SIGINT, ctrlc)
    kernel32 = ctypes.CDLL('kernel32.dll')
    #print kernel32
    print 'Bye!'

    return 0

if __name__ == '__main__' :

Open in new window

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.

kernel32 = cdll.<dll name="kernel32.dll">

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:
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

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.