closes bpo-38692: Add a pidfd child process watcher to asyncio. (GH-17069)

This commit is contained in:
Benjamin Peterson 2019-11-13 19:08:50 -08:00 committed by GitHub
parent dad6be5ffe
commit 3ccdd9b180
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 102 additions and 0 deletions

View file

@ -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):