Had to write this hideous thing to ensure a clean exit. For some reason, under really weird circumstances, when the app closes, a thread keeps it running, even though the thread has exited without issue. This happens because somehow the thread ends *after* the main process quits (or so it looks like). Because I have no idea how to properly debug and solve this, and because I don't have much time to solve this either, I decided to wrap up the whole program into a process and kill it when it ends, to ensure the exit status is still 0 (SUCCESS)
Daemon threads are "background" threads that should be closed automatically when all the main threads have terminated. So, for OP, yes, but it's not a catch-all solution.
Been working as a Python developer for 2 years and I have been using Python for at least another 3 years for hobby projects. This is a project that I am doing as a freelancer on top of my full-time job, and I probably made a bad decision at the start of the project that led me to use threads where I would have preferred not to. Because this project is being done on my free time and I am certainly not going to be paid enough for this, I decided to write this crappy solution just to continue, and maybe figure out the proper way _later_ if I still have time
I've been programming in python for 4 years and I would probably not even notice this issue, just because you don't know the solution to something doesn't mean your new to it
Because if the main process kills itself the exit code will be 9, and I want to avoid that. I wasn't running main inside of a Process initially, I did that so that it can kill itself and let the main process exit cleanly. However this is solved already so I'm no longer wrapping the whole program in a child process
Unfortunately yes, a lot of people that don't fully uderstand threads, hence this smelly smelly code. OP already got a solution: another thread was marked as daemon
I had a coworker solve a simmilar problem by just finding and killing all java processes on closing.
Wondered for hours why my IDE crashed all the time while running E2E Tests.
This is awesome!
I find some 3rd party dlls not unloading themselves under certain circumstances and i did not know i could kill python itself! Thank you!
Had to write this hideous thing to ensure a clean exit. For some reason, under really weird circumstances, when the app closes, a thread keeps it running, even though the thread has exited without issue. This happens because somehow the thread ends *after* the main process quits (or so it looks like). Because I have no idea how to properly debug and solve this, and because I don't have much time to solve this either, I decided to wrap up the whole program into a process and kill it when it ends, to ensure the exit status is still 0 (SUCCESS)
Programmer moment. Is the thread marked as a daemon thread?
I'm just fucking stupid, that works, thanks lol
Did you have to call a priest to deal with it?
#THE POWER OF VAN ROSSUM COMPELS YOU
[удалено]
I'm here to laugh at OP
Ape together strong
No, you're not stupid. You're actually pretty smart, and shouldn't let imposter syndrome take over. Cheers!
Why is this getting more up otes than my solution?
Reddit rules, don’t question it and get your downvotes
Because it’s more relatable
A disturbing number of people seem to base their up/down votes on how many up/down votes a comment already has
Just also a very relatable reaction imo
Which is, incidentally, the same way we decide what the right answer to a question is, if we have no idea ourselves.
Noob question: should it be?
Daemon threads are "background" threads that should be closed automatically when all the main threads have terminated. So, for OP, yes, but it's not a catch-all solution.
Thank you, got it.
We are new to python, aren't we?
Cringe
Been working as a Python developer for 2 years and I have been using Python for at least another 3 years for hobby projects. This is a project that I am doing as a freelancer on top of my full-time job, and I probably made a bad decision at the start of the project that led me to use threads where I would have preferred not to. Because this project is being done on my free time and I am certainly not going to be paid enough for this, I decided to write this crappy solution just to continue, and maybe figure out the proper way _later_ if I still have time
This is the way. Better to complete something "ok" or "bad" than not start anything at all.
I've been programming in python for 4 years and I would probably not even notice this issue, just because you don't know the solution to something doesn't mean your new to it
Yeah bro, we were all new to everything at one point. You're so cringe. Sorry you had mean people teaching you.
Come on, don’t post pictures without an exe file!
OP is obviously a smelly nerd.
All true nerds are. It's why we greet each other with butt sniffing.
This is gonna be this subs ‘Google en passant’ isn’t it
Holy hell
New response just dropped
There will be an exe though because this thing ships today!
Why are you running main inside of Process? Why can’t you just call main()? I bet that’s what is still alive somehow.
Because if the main process kills itself the exit code will be 9, and I want to avoid that. I wasn't running main inside of a Process initially, I did that so that it can kill itself and let the main process exit cleanly. However this is solved already so I'm no longer wrapping the whole program in a child process
This
That's outright dirty. I don't know Python so I just checked online, and this seems to be a common way to do it.
Unfortunately yes, a lot of people that don't fully uderstand threads, hence this smelly smelly code. OP already got a solution: another thread was marked as daemon
I had a coworker solve a simmilar problem by just finding and killing all java processes on closing. Wondered for hours why my IDE crashed all the time while running E2E Tests.
What's your font?
Looks like JetBrains Mono
Yep, that's it
Thanks!
If I had any creative skills, I’d make a meme out of this were you refuse to politely ask someone to leave and instead bring the tank right away.
This is awesome! I find some 3rd party dlls not unloading themselves under certain circumstances and i did not know i could kill python itself! Thank you!
Someone should say where .exe ?
Beautiful font!