S
S
Sanya Hihi Haha2020-06-05 12:36:07
Python
Sanya Hihi Haha, 2020-06-05 12:36:07

How to purposefully kill a thread?

Good afternoon.
I have a VK bot that accepts a link from the user and then starts clicking on it and other links within the site, of course it does it in threads, maybe a separate user = a separate thread, because you need to do it for all users at the same time

There is a "stop" button in the bot which should end the thread

Here is the start of the thread

race_thread = threading.Thread(target=AutoRacer().StartWork(auth_link,), name='thread: {}'.format(sender))
race_thread.start()


Yes, I know that killing a thread is a super bad idea, but I don't see any other options here yet. It would be desirable to kill a stream by name.

I have no options to wait for self-completion, thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bbkmzzzz, 2020-06-05
@bbkmzzzz

For each thread, create a flag variable, for example, running, the thread periodically checks it, if it is False, it terminates its work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question