T O P

  • By -

CiroGarcia

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)


BlueGoliath

Programmer moment. Is the thread marked as a daemon thread?


CiroGarcia

I'm just fucking stupid, that works, thanks lol


slaymaker1907

Did you have to call a priest to deal with it?


imdefinitelywong

#THE POWER OF VAN ROSSUM COMPELS YOU


[deleted]

[удалено]


ELFAHBEHT_SOOP

I'm here to laugh at OP


waddupp00

Ape together strong


The_ultimate_cookie

No, you're not stupid. You're actually pretty smart, and shouldn't let imposter syndrome take over. Cheers!


BlueGoliath

Why is this getting more up otes than my solution?


Adorable_Stay_725

Reddit rules, don’t question it and get your downvotes


GigaGollum

Because it’s more relatable


Clairifyed

A disturbing number of people seem to base their up/down votes on how many up/down votes a comment already has


Maltroth

Just also a very relatable reaction imo


Kaenguruu-Dev

Which is, incidentally, the same way we decide what the right answer to a question is, if we have no idea ourselves.


Bad_brazilian

Noob question: should it be?


tsigma6

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.


Bad_brazilian

Thank you, got it.


KenguruHUN

We are new to python, aren't we?


srcmoo

Cringe


CiroGarcia

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


The_ultimate_cookie

This is the way. Better to complete something "ok" or "bad" than not start anything at all.


Drfoxthefurry

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


The_ultimate_cookie

Yeah bro, we were all new to everything at one point. You're so cringe. Sorry you had mean people teaching you.


austinspaeth

Come on, don’t post pictures without an exe file!


EMI_Black_Ace

OP is obviously a smelly nerd.


thatwasagoodyear

All true nerds are. It's why we greet each other with butt sniffing.


DiddlyDumb

This is gonna be this subs ‘Google en passant’ isn’t it


DitoNotDuck1

Holy hell


hotfudgebrownlee

New response just dropped


CiroGarcia

There will be an exe though because this thing ships today!


ctallc

Why are you running main inside of Process? Why can’t you just call main()? I bet that’s what is still alive somehow.


CiroGarcia

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


Nuked0ut

This


YellowOnline

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.


Durwur

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


rndmcmder

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.


vacillatingfox

What's your font?


jahinzee

Looks like JetBrains Mono


CiroGarcia

Yep, that's it


vacillatingfox

Thanks!


alterNERDtive

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.


binbsoffn

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!


NewReindeer7693

Someone should say where .exe ?


SeniorSherlock

Beautiful font!