Working with Threads - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Working with Threads (/thread-32291.html) |
Working with Threads - Gilush - Feb-02-2021 Hi all, So I have this small program that does multiple actions:
I'm struggeling with terminating the thread with "when" condition or "if" condition but I still get 2 threads running infintly. this is the output I get (no errors): Quote:| Mouse: False | Screen: True | Keylogger: True | Upload: False EDIT: Problem solved. RE: Working with Threads - nilamo - Feb-03-2021 Quote:EDIT: Problem solved.For anyone stumbling upon this in the future, I recommend using a simple Event object. The long-running threads can just check if event.is_set() , and when you want them all to stop, you set it, so they know to stop: event.set() . The Event object will handle all the details for you to make it thread safe.https://docs.python.org/3/library/threading.html#event-objects RE: Working with Threads - Gilush - Feb-04-2021 That is exactly the solution I used in my code. (since the code is an offensive cyber oriented project I removed it from the post.) Should have posted the solution though.. thanks for posting it! |