Login Register






Loop causes not responding[PYTHON] filter_list
Author
Message
Loop causes not responding[PYTHON] #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.

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()
So how do i make this work without freezing?

Reply

RE: Loop causes not responding[PYTHON] #2
Still hot thread for me.. BUMP

Reply

RE: Loop causes not responding[PYTHON] #3
the loop is (maybe) infinite which is causing it to freeze.
[Image: fow57.jpg]

Reply

RE: Loop causes not responding[PYTHON] #4
(01-07-2013, 02:04 PM)H4R0015K Wrote: the loop is (maybe) infinite which is causing it to freeze.

Yes, true.. only way to exit it is by clicking on other button "stop" which will start another function. But i still made a delay in that loop with time.sleep(6) <- which will pause it for 6 seconds.. Shouldn't that prevent it from freezing?

Reply

RE: Loop causes not responding[PYTHON] #5
I don't do Python, but if you have a GUI and you don't want it to freeze, you usually use threads for tasks that take long.
sleep won't help, when it makes the thread sleep that renders the GUI.

Stackoverflow states three ways to solve this: http://stackoverflow.com/questions/14896...ning-tasks
Have a look at that.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Loop causes not responding[PYTHON] #6
OH, thank you! You have no idea how much you helped..

I'm requesting mod to close this thread..
It's answered

Reply