python - thread
Posted: Thu Aug 28, 2008 7:36 pm
i don't know much about threading, but been trying to write a script, that would time limit execution of eval() function;
i've tried writing some example code, but it's not working - it's waiting for the thread to complete...
Any ideas what's wrong?
i've tried writing some example code, but it's not working - it's waiting for the thread to complete...
Code: Select all
import thread
import time
status = ""
result = 0
def s_eval(code):
global status
global result
print eval(code)
status = "finished"
th = thread.start_new_thread(s_eval, ('9999999999**999999',))
time.sleep(5)
if status != "finished":
th.exit()