Exiting a multiprocessed python application safely

0 votes
When we use-  os._exit(<num>) ::

Exit the process with status n, without calling cleanup handlers, flushing stdio buffers, etc.

and that sys.exit() ::

“only” raises an exception, it will only exit the process when called from the main thread

Now, how do I close a multi-processed application that will ensure all processes are closed (none left orphaned) and that it exits in the best state possible?

Also, I am creating the processes using the python multiprocessing library, by creating classes which inherit from multiprocessing Process.
May 6, 2019 in Python by ana1504.k
• 7,910 points
1,496 views

1 answer to this question.

0 votes
I ended up creating a Pipe for every Process. Then when the main Process shuts down it can send a message to all the children Processes that they should shut down too.

In order to make that work right you've got to put a periodic check into the children Processes' "do loop" to see if there are messages in the pipe, and if so, check them to see if it's a "quit now" message.
answered May 6, 2019 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

Exiting a python program

Use the quit() function. This function can ...READ MORE

answered May 8, 2018 in Python by Nietzsche's daemon
• 4,260 points
295 views
0 votes
0 answers

If in Python I put a list inside a tuple, can I safely change the contents of that list?

The value inside the tuple is simply ...READ MORE

Apr 26, 2022 in Python by Edureka
• 13,620 points
282 views
+3 votes
7 answers

How can I rename a file in Python?

yes, you can use "os.rename" for that. ...READ MORE

answered Mar 31, 2018 in Python by DareDev
• 6,890 points
19,316 views
+2 votes
2 answers

How can I create a new file in Python?

You can try the below code which ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
958 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,023 views
0 votes
1 answer
0 votes
1 answer

Is there a string 'contains' in python?

In this case, you can use the ...READ MORE

answered Sep 25, 2018 in Python by SDeb
• 13,300 points
504 views
0 votes
1 answer

How to Reverse a list in Python

You can use the reversed function in ...READ MORE

answered Sep 29, 2018 in Python by SDeb
• 13,300 points
636 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP