I start a thread that runs exec and sets the global variable to True, meaning that the thread finished. The main thread that creates this new thread runs in a loop while the global var is False. The problem is that the exec job is also running in a loop and it's not known when will it finish and right now it seems that exec never finishes if i put a condition with an sys.exit somewhere. If I put the os._exit then everything finishes, the exec, the new thread and the main thread. But i need something that only stops exec and moves on (and the new thread finishes by itself). Is there any way to do this? I cannot just use return, because i need to exit deep inside some function call in exec.

9 Years
Discussion Span
Last Post by invinate

Hi, it would be really handy if you could post your code. That way we can look at it and try and debug it that way.

Hi, yes, it's hard to figure out what's going on from the description, but it just not possible to post all the code, there's just too much stuff going on there, but here's the relevant parts:
main thread:

jobthread = Thread(target=runjob,args=(jobcompiled))
while(not jobterminated ):
# do stuff


# The code after exec does not execute!!!
jobterminated = True

I tried putting os._exit and sys.exit in the executing job (jobcompiled, a python script), but still it doesnt reach the code after exec

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.