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

Recommended Answers

All 2 Replies

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, 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))
jobthread.start()
....
while(not jobterminated ):
# do stuff

runjob:

...
exec(job,arglist,arglist)
# 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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.