mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
closes bpo-38692: Add a pidfd child process watcher to asyncio. (GH-17069)
This commit is contained in:
parent
dad6be5ffe
commit
3ccdd9b180
5 changed files with 102 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import signal
|
||||
import sys
|
||||
import unittest
|
||||
|
@ -691,6 +692,23 @@ if sys.platform != 'win32':
|
|||
|
||||
Watcher = unix_events.FastChildWatcher
|
||||
|
||||
def has_pidfd_support():
|
||||
if not hasattr(os, 'pidfd_open'):
|
||||
return False
|
||||
try:
|
||||
os.close(os.pidfd_open(os.getpid()))
|
||||
except OSError:
|
||||
return False
|
||||
return True
|
||||
|
||||
@unittest.skipUnless(
|
||||
has_pidfd_support(),
|
||||
"operating system does not support pidfds",
|
||||
)
|
||||
class SubprocessPidfdWatcherTests(SubprocessWatcherMixin,
|
||||
test_utils.TestCase):
|
||||
Watcher = unix_events.PidfdChildWatcher
|
||||
|
||||
else:
|
||||
# Windows
|
||||
class SubprocessProactorTests(SubprocessMixin, test_utils.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue