mirror of
https://github.com/python/cpython.git
synced 2025-11-08 17:41:42 +00:00
gh-83856: Honor atexit for all multiprocessing start methods (GH-114279)
Use atexit for all multiprocessing start methods to cleanup. See the GH-114279 PR discussion and related issue for details as to why.
This commit is contained in:
parent
cb57a52a85
commit
998c3856c1
5 changed files with 34 additions and 5 deletions
|
|
@ -6161,6 +6161,29 @@ def submain(): pass
|
|||
self.assertFalse(err, msg=err.decode('utf-8'))
|
||||
|
||||
|
||||
class _TestAtExit(BaseTestCase):
|
||||
|
||||
ALLOWED_TYPES = ('processes',)
|
||||
|
||||
@classmethod
|
||||
def _write_file_at_exit(self, output_path):
|
||||
import atexit
|
||||
def exit_handler():
|
||||
with open(output_path, 'w') as f:
|
||||
f.write("deadbeef")
|
||||
atexit.register(exit_handler)
|
||||
|
||||
def test_atexit(self):
|
||||
# gh-83856
|
||||
with os_helper.temp_dir() as temp_dir:
|
||||
output_path = os.path.join(temp_dir, 'output.txt')
|
||||
p = self.Process(target=self._write_file_at_exit, args=(output_path,))
|
||||
p.start()
|
||||
p.join()
|
||||
with open(output_path) as f:
|
||||
self.assertEqual(f.read(), 'deadbeef')
|
||||
|
||||
|
||||
class MiscTestCase(unittest.TestCase):
|
||||
def test__all__(self):
|
||||
# Just make sure names in not_exported are excluded
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue