python 3.7 - I try to close the thread without closing the GUI is it possible?
alon.najman at gmail.com writes:
> python 3.7 - I try to close the thread without closing the GUI is it possible?
I assume that with "close a thread" you mean "terminate a thread".
It is difficult to terminate a thread from the outside, because
on many platforms, there is no reliable way to terminate an
(operating system level) thread in a safe way.
The easiest thing would be that you prepare your thread to
terminate (on its own) when the outside world sets a flag
that it should terminate.
In Python 2, there has been a C level Python function
which allows to indicate to a thread that it should terminate.
It implements the approach from the previous paragraph but
at the Python interpreter level. It cannot stop a thread
if it is not executing Python code (but somewhere in a "C" extension).
Not sure, whether this function is available in Python 3.
It might be possible that you move the activity now done in a
thread into a process. Terminating a process is far easier
than terminating a thread.