Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a way to determine if a process has been closed or not #87063

Open
petervansickel mannequin opened this issue Jan 11, 2021 · 3 comments
Open

Expose a way to determine if a process has been closed or not #87063

petervansickel mannequin opened this issue Jan 11, 2021 · 3 comments
Labels
topic-multiprocessing type-feature A feature request or enhancement

Comments

@petervansickel
Copy link
Mannequin

petervansickel mannequin commented Jan 11, 2021

BPO 42897
Nosy @petervansickel

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-01-11.19:55:45.985>
labels = ['type-feature', '3.10']
title = 'Expose a way to determine if a process has been closed or not'
updated_at = <Date 2021-01-11.19:55:45.985>
user = 'https://github.com/petervansickel'

bugs.python.org fields:

activity = <Date 2021-01-11.19:55:45.985>
actor = 'petervansickel'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2021-01-11.19:55:45.985>
creator = 'petervansickel'
dependencies = []
files = []
hgrepos = []
issue_num = 42897
keywords = []
message_count = 1.0
messages = ['384860']
nosy_count = 1.0
nosy_names = ['petervansickel']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue42897'
versions = ['Python 3.10']

Linked PRs

@petervansickel
Copy link
Mannequin Author

petervansickel mannequin commented Jan 11, 2021

I have been using the multiprocessing Process class a good bit lately. I have a class that is managing the a given list of processes from launch to completion.
Recently I started using Process close(). I found myself wanting to determine if a given process instance was closed or not before I did anything like check its exitcode or invoke any of the other methods that raise a ValueError if done so on a closed process.
As far as I can tell there is no exposed way to check if the process is closed. The Process class has a _closed instance variable and a _check_closed() method, but those are not intended for direct use.
I created a simple wrapper class that has its own closed instance variable and wraps the close() method of Process so that the closed instance variable can be set to True when close() is called and then call super().close() to allow the normal close operation to complete.
It would be convenient if the Process class itself supported an is_closed() method or exposed a Boolean closed attribute to easily determine if a process instance has been closed.

@petervansickel petervansickel mannequin added 3.10 only security fixes type-feature A feature request or enhancement labels Jan 11, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@erlend-aasland erlend-aasland removed the 3.10 only security fixes label Oct 23, 2024
@erlend-aasland
Copy link
Contributor

FTR, close was added by @pitrou in #74781 (PR #2010). There was no discussion regarding a closed attribute at that time.

@erlend-aasland
Copy link
Contributor

I'm not sure convenience is a good enough reason to add this API; the workaround in the OP is straight-forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-multiprocessing type-feature A feature request or enhancement
Projects
Status: No status
Development

No branches or pull requests

2 participants