Python Threading Issues /u/Lyricfoil Python Education

I have a threading function that waits for user input to kill all threads, but it doesn’t seem to want to finish. Currently I have it as “while not stop_event.is_set()” then beneath that “if input(…)” then stop_event.set() if the user inputs the enter key.

However, no matter what I do I can’t seem to get this thread to finish! I’ve tried setting the stop_event.set() to trigger right after the last function in the main() threads .join’s but this function never joins! I’m suspecting that the Python input() is getting the script locked into waiting for user’s input and never actually needs the input unless something goes wrong.

If I’m correct, maybe I should use pynput? Just listen for the special key in the while loop? Idk it’s annoying. (It’s probably something basic too so I’m sorry )

submitted by /u/Lyricfoil
[link] [comments]

​r/learnpython I have a threading function that waits for user input to kill all threads, but it doesn’t seem to want to finish. Currently I have it as “while not stop_event.is_set()” then beneath that “if input(…)” then stop_event.set() if the user inputs the enter key. However, no matter what I do I can’t seem to get this thread to finish! I’ve tried setting the stop_event.set() to trigger right after the last function in the main() threads .join’s but this function never joins! I’m suspecting that the Python input() is getting the script locked into waiting for user’s input and never actually needs the input unless something goes wrong. If I’m correct, maybe I should use pynput? Just listen for the special key in the while loop? Idk it’s annoying. (It’s probably something basic too so I’m sorry ) submitted by /u/Lyricfoil [link] [comments] 

I have a threading function that waits for user input to kill all threads, but it doesn’t seem to want to finish. Currently I have it as “while not stop_event.is_set()” then beneath that “if input(…)” then stop_event.set() if the user inputs the enter key.

However, no matter what I do I can’t seem to get this thread to finish! I’ve tried setting the stop_event.set() to trigger right after the last function in the main() threads .join’s but this function never joins! I’m suspecting that the Python input() is getting the script locked into waiting for user’s input and never actually needs the input unless something goes wrong.

If I’m correct, maybe I should use pynput? Just listen for the special key in the while loop? Idk it’s annoying. (It’s probably something basic too so I’m sorry )

submitted by /u/Lyricfoil
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *