mirror of
https://github.com/python/cpython.git
synced 2025-09-09 02:11:51 +00:00
Issue #12040: Expose a new attribute sentinel
on instances of
:class:`multiprocessing.Process`. Also, fix Process.join() to not use polling anymore, when given a timeout.
This commit is contained in:
parent
f068ab8304
commit
176f07dadf
6 changed files with 108 additions and 14 deletions
|
@ -132,6 +132,7 @@ class Process(object):
|
|||
else:
|
||||
from .forking import Popen
|
||||
self._popen = Popen(self)
|
||||
self._sentinel = self._popen.sentinel
|
||||
_current_process._children.add(self)
|
||||
|
||||
def terminate(self):
|
||||
|
@ -218,6 +219,17 @@ class Process(object):
|
|||
|
||||
pid = ident
|
||||
|
||||
@property
|
||||
def sentinel(self):
|
||||
'''
|
||||
Return a file descriptor (Unix) or handle (Windows) suitable for
|
||||
waiting for process termination.
|
||||
'''
|
||||
try:
|
||||
return self._sentinel
|
||||
except AttributeError:
|
||||
raise ValueError("process not started")
|
||||
|
||||
def __repr__(self):
|
||||
if self is _current_process:
|
||||
status = 'started'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue