Skip to content

Commit 5ed7d32

Browse files
authored
Remove unnecessary asyncio EventLoopPolicy init_watcher backport (#129628)
1 parent ab5b9db commit 5ed7d32

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

homeassistant/runner.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
from __future__ import annotations
44

55
import asyncio
6-
from asyncio import events
76
import dataclasses
87
import logging
9-
import os
108
import subprocess
119
import threading
1210
from time import monotonic
@@ -58,46 +56,13 @@ class RuntimeConfig:
5856
safe_mode: bool = False
5957

6058

61-
def can_use_pidfd() -> bool:
62-
"""Check if pidfd_open is available.
63-
64-
Back ported from cpython 3.12
65-
"""
66-
if not hasattr(os, "pidfd_open"):
67-
return False
68-
try:
69-
pid = os.getpid()
70-
os.close(os.pidfd_open(pid, 0))
71-
except OSError:
72-
# blocked by security policy like SECCOMP
73-
return False
74-
return True
75-
76-
7759
class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
7860
"""Event loop policy for Home Assistant."""
7961

8062
def __init__(self, debug: bool) -> None:
8163
"""Init the event loop policy."""
8264
super().__init__()
8365
self.debug = debug
84-
self._watcher: asyncio.AbstractChildWatcher | None = None
85-
86-
def _init_watcher(self) -> None:
87-
"""Initialize the watcher for child processes.
88-
89-
Back ported from cpython 3.12
90-
"""
91-
with events._lock: # type: ignore[attr-defined] # noqa: SLF001
92-
if self._watcher is None: # pragma: no branch
93-
if can_use_pidfd():
94-
self._watcher = asyncio.PidfdChildWatcher()
95-
else:
96-
self._watcher = asyncio.ThreadedChildWatcher()
97-
if threading.current_thread() is threading.main_thread():
98-
self._watcher.attach_loop(
99-
self._local._loop # type: ignore[attr-defined] # noqa: SLF001
100-
)
10166

10267
@property
10368
def loop_name(self) -> str:

0 commit comments

Comments
 (0)