Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
You mean multiprocess, not multi threaded...
And you can pass the parent pid to the child, and keep the child pids in the parent. Then propagate the signal to each process using a signal trap. -
@magicMirror I'm actually using the Thread class in Python, and I know there's also a subprocess library, but correct me if I'm wrong
-
You could also use thread.daemon=True, but it might not be recommended. Reference: https://stackoverflow.com/questions...
-
@electrineer well, I solved the problem by using a shared boolean variable between the parent thread and the child thread, instead of doing connection shenanigans actually
-
@shinypotato If tou are using threads... then whats the point of trapping signals? just exit the process...
Related Rants
Been working for a while with some terrible code with no documentation that I just inherited from a previous employee
Topic: multi-threaded program in Python
Goal: kill both parent and children with keyboard interrupt
Intuitive idea: check in children processes if parent still alive
Implemented idea:
- parent creates socket connection
- keyboard interrupt kills parent and thus the socket connection as well
- children receive some specific socket error from the loss of connection
- children catch the exception and are killed
In Python 2, of course
I, too, like to inflict pain on myself for fun
rant
multi-threaded
connection
socket
python