0

I have a code with this loop:

code = 'for i in range(1,1000):
    print(i)'

This code is executed from inside a thread class TestThread:

testThread = TestsThread(self, code, autostart)
testThread.start()

Inside a this thread there an exec: with the code above:

exec(code, globals())

Now I would like stop or pause loop at some point, when an event did fired, something like pause a thread.

Some idea?

Luca Becchetti
  • 1,210
  • 1
  • 12
  • 28
  • What have you tried so far? Did nothing from [here](https://www.geeksforgeeks.org/python-different-ways-to-kill-a-thread/) work for you? – Random Davis Nov 25 '20 at 17:31
  • All this methods are nice, the problem is that I do not no the code I will exec, so I cannot periodically pull for exit status var, I receive a event from socket.io and I have to kill immediately the thread. – Luca Becchetti Nov 26 '20 at 11:38

0 Answers0