Loop causes not responding[PYTHON] 01-05-2013, 08:06 PM
#1
Hello [username]. I made a GUI program for counterstrike 1.6, which protects players configuration from malicious "virus"/"bad configuration" that can be lunched by administrator on any server.
You don't need to read the red text, but it won't kill you if you would.
When admin "censures" you, instantly new file called "censuree.cfg" is being downloaded to your CSTRIKE folder and changes your original configuration to chaos. The way to get out of that "censure" is simply by deleting censuree.cfg and replacing your config.cfg with new one.
Anyway.. my code has to loop and i made a delay with time.sleep(6) Which will pause my program for 6 seconds, so i could prevent it from 'not responding' BUT, according to my friends who tested it ( including me) they still got 'not responding' But program still works ( function of program ). Problem is that there is no way you can stop it excluding by ending the process or making force exit.. Do you know how i could make a better delay, so it doesn't freeze ( I also don't want to increase length of delay) :/? Heres is the code in my program that's main function, also when started causes freezing but works.
So how do i make this work without freezing?
You don't need to read the red text, but it won't kill you if you would.
When admin "censures" you, instantly new file called "censuree.cfg" is being downloaded to your CSTRIKE folder and changes your original configuration to chaos. The way to get out of that "censure" is simply by deleting censuree.cfg and replacing your config.cfg with new one.
Anyway.. my code has to loop and i made a delay with time.sleep(6) Which will pause my program for 6 seconds, so i could prevent it from 'not responding' BUT, according to my friends who tested it ( including me) they still got 'not responding' But program still works ( function of program ). Problem is that there is no way you can stop it excluding by ending the process or making force exit.. Do you know how i could make a better delay, so it doesn't freeze ( I also don't want to increase length of delay) :/? Heres is the code in my program that's main function, also when started causes freezing but works.
Code:
def activated1():
cstrikefolder = cstrike.get() # Gets the value of user input ( his cstrike folder path)
dir = os.getcwd() # Gets current part of working directory
time.sleep(6) # <--Main problem. This should make delay to prevent freezing
if os.path.isfile(cstrikefolder+"\censuree.cfg"): #Checks if censuree.cfg exists
os.remove(cstrikefolder+"\censuree.cfg") # If it does exist then remove it ( censuree.cfg )
shutil.copy2(dir+'\config.cfg', cstrikefolder+"\config.cfg") # And also copy the config.cfg from working directory ( replacing good confing with bad one)
activated1()
else:
activated1()


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
![[Image: fow57.jpg]](http://i.imgur.com/fow57.jpg)
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)