python - thread

Discussion about hacker.org's server
Post Reply
The_Dark_Avenger
Posts: 115
Joined: Wed Jun 11, 2008 9:47 pm

python - thread

Post by The_Dark_Avenger »

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

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()
Any ideas what's wrong?
Post Reply