5
I have a loop while
that ends only when I press the key q, then the program is closed. Within that loop, at a given time or condition, I initiate a thread that takes about a few 10 seconds to run.
My problem is, if I get out of loop squeezing q with a thread running, this is canceled.
I would like the loop/script awaited the execution of the thread, and then finalize the program. This is possible?
Thank you.
Dude, could you put in the relevant part of your code? I think it’s kind of abstract with nothing in the code...
– Felipe Avelar
But possibly using a
thread.isAlive()
solve your problem...– Felipe Avelar
@Felipeavelar, thanks for the feedback. I can even use the.isAlive() thread to detect if it exists, but how to "wait" for the thread to close? Ah, another thing, I realized that even if I shut down the program and went back to the prompt, the thread keeps running until it’s finished, in a way that’s good, I just wanted it to wait to get back to the prompt.
– Daniel Accorsi
Could put a
while thread.isAlive(): pass
. But I can’t say with precision, without seeing the code.– Felipe Avelar