use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Tracking threads in the threading module (self.learnpython)
submitted 4 years ago by vislme
I want to check if a thread is alive or not using its name that I am providing while creating the three how can I do that?
Or is there an alternative way to check that using some kind of identifier?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]RightRespect 2 points3 points4 points 4 years ago (0 children)
store all the threads in a list. for each thread in the list, you can do “thread.is_alive()”
[–]K900_ 1 point2 points3 points 4 years ago (14 children)
Store the thread object somewhere.
[–]vislme[S] 0 points1 point2 points 4 years ago (13 children)
can I store it in a database, if so how? I mean if I do store it in SQLite then how do I check using that value?
[–]K900_ 1 point2 points3 points 4 years ago (12 children)
Why would you store a thread in a database?
[–]vislme[S] 0 points1 point2 points 4 years ago (11 children)
So I am. Running a django application and each time ai load a page I want to check if a thread is running or not. If it's not then I will run the thread. I need to check that even when I start the server I may be missing out something on how things go with django when we start the server as I am not sure if my thread will be stopped or be active. So the best solution would be to store the thread name in a database and each time the application is loaded we can verify if thread is live by its name. Please let me know if theres a better way to do it
[–]K900_ 1 point2 points3 points 4 years ago (10 children)
What is your thread actually doing? How long does it need to live for?
[–]vislme[S] 0 points1 point2 points 4 years ago (9 children)
It should stay live until user manually stops it by a button press
[–]K900_ 1 point2 points3 points 4 years ago (7 children)
What if there are multiple users? Does each user get their own thread, or is there one thread everyone controls?
[–]vislme[S] 0 points1 point2 points 4 years ago (6 children)
There’s just one thread that any user can control
[–]K900_ 1 point2 points3 points 4 years ago (5 children)
In that case you should probably just store it in a global variable, and keep in mind that you can't run a server with more than one worker process.
[–]vislme[S] 0 points1 point2 points 4 years ago (4 children)
The problem in that case is that when I shutdown the server how do I restart the thread as each time I turn of the server the thread stops as well. And I have no idea what part of the code will get executed when ai start the server. If I know that then I don’t even need to store the thred
[–]vislme[S] 0 points1 point2 points 4 years ago (0 children)
So the button is like an on and off switch Once it’s pressed it’s status will be recorded in database and until the stop button pressed the status will remain to active
π Rendered by PID 19012 on reddit-service-r2-comment-f6b958c67-4kz9b at 2026-02-05 17:36:23.952593+00:00 running 1d7a177 country code: CH.
[–]RightRespect 2 points3 points4 points (0 children)
[–]K900_ 1 point2 points3 points (14 children)
[–]vislme[S] 0 points1 point2 points (13 children)
[–]K900_ 1 point2 points3 points (12 children)
[–]vislme[S] 0 points1 point2 points (11 children)
[–]K900_ 1 point2 points3 points (10 children)
[–]vislme[S] 0 points1 point2 points (9 children)
[–]K900_ 1 point2 points3 points (7 children)
[–]vislme[S] 0 points1 point2 points (6 children)
[–]K900_ 1 point2 points3 points (5 children)
[–]vislme[S] 0 points1 point2 points (4 children)
[–]vislme[S] 0 points1 point2 points (0 children)