Issue 12040: Expose a Process.sentinel property (and fix polling loop in Process.join())
Created on 2011-05-09 18:39 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| process_sentinel.patch | pitrou, 2011-05-09 18:39 | review | ||
| process_sentinel2.patch | pitrou, 2011-05-12 16:18 | review | ||
| Messages (6) | |||
|---|---|---|---|
| msg135623 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2011-05-09 18:39 | |
This patch exposes a new read-only property of multiprocessing.Process objects, named "sentinel". As the doc indicates, this is a file descriptor undex Unix, and a handle under Windows. Both are suitable for flexible polling/waiting with the appropriate OS primitives. They become ready when the process has ended. Under Unix, this also replaces the repeated polling in _Popen.wait() (called from Process.join()) with a regular select() call, making it friendlier with CPU low-power states. This is necessary for issue9205. |
|||
| msg135844 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2011-05-12 16:18 | |
Here is a new patch addressing Gregory's comment (retry select() on EINTR). |
|||
| msg135929 - (view) | Author: Gregory P. Smith (gregory.p.smith) * ![]() |
Date: 2011-05-13 17:08 | |
That looks better. :) btw, that eintr_retry utility probably deserves to be in a more prominent place in the stdlib but I don't have a good suggestion as to where at the moment. I believe similar code exists in many places in the code base. If it is not going to be documented as an official multiprocessing.util function, rename it to _eintr_retry(). that way it'll be easier to move to a new place in the library if/when we do want to make it public. |
|||
| msg135930 - (view) | Author: Charles-François Natali (neologix) * ![]() |
Date: 2011-05-13 17:09 | |
Just a detail, but with the last version, select is retried with the full timeout (note that the signal you're the most likely to receive is SIGCHLD and since it's ignored by default it won't cause EINTR, so this shouldn't happen too often). By the way, it's not the first time EINTR-issues pop up: would it be possible/worth it/interesting to expose this kind of wrapper somewhere (even as a private API), or a context manager ? |
|||
| msg136087 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2011-05-16 13:51 | |
> Just a detail, but with the last version, select is retried with the > full timeout (note that the signal you're the most likely to receive > is SIGCHLD and since it's ignored by default it won't cause EINTR, so > this shouldn't happen too often). Indeed, it is. In practice we don't see anyone complaining about EINTR issues, so I guess it's quite rare anyway. > By the way, it's not the first time EINTR-issues pop up: would it be > possible/worth it/interesting to expose this kind of wrapper somewhere > (even as a private API), or a context manager ? Yes, but where? |
|||
| msg137758 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2011-06-06 17:36 | |
New changeset 568a3ba088e4 by Antoine Pitrou in branch 'default': Issue #12040: Expose a new attribute `sentinel` on instances of http://hg.python.org/cpython/rev/568a3ba088e4 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:17 | admin | set | github: 56249 |
| 2011-06-06 17:39:01 | pitrou | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2011-06-06 17:36:07 | python-dev | set | nosy:
+ python-dev messages: + msg137758 |
| 2011-05-16 13:51:58 | pitrou | set | messages: + msg136087 |
| 2011-05-13 17:09:57 | neologix | set | messages: + msg135930 |
| 2011-05-13 17:08:50 | gregory.p.smith | set | messages: + msg135929 |
| 2011-05-12 16:18:41 | pitrou | set | files:
+ process_sentinel2.patch messages: + msg135844 |
| 2011-05-09 21:47:28 | vstinner | set | nosy:
+ vstinner |
| 2011-05-09 18:40:42 | pitrou | link | issue9205 dependencies |
| 2011-05-09 18:39:21 | pitrou | create | |

