Skip to content

Commit

Permalink
Remove event loop's support for child watchers for 3.14+
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed Aug 7, 2024
1 parent 9dbc5d2 commit 2142c46
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ jobs:
# M1 runners
"macos-14"
]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev", "3.14-dev" ]
include:
- experimental: false
- python-version: "3.13-dev"
experimental: true
- python-version: "3.14-dev"
experimental: true

exclude:
# actions/setup-python doesn't provide Python3.8 or 3.9 for M1.
Expand Down
33 changes: 19 additions & 14 deletions src/rubicon/objc/eventloop.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""PEP 3156 event loop based on CoreFoundation."""

import contextvars
import sys
import threading
from asyncio import (
DefaultEventLoopPolicy,
SafeChildWatcher,
coroutines,
events,
tasks,
Expand All @@ -16,6 +16,9 @@
from .runtime import load_library, objc_id
from .types import CFIndex

if sys.version_info < (3, 14):
from asyncio import SafeChildWatcher

__all__ = [
"EventLoopPolicy",
"CocoaLifecycle",
Expand Down Expand Up @@ -702,23 +705,25 @@ def _init_watcher(self):
if threading.current_thread() == threading.main_thread():
self._watcher.attach_loop(self._default_loop)

def get_child_watcher(self):
"""Get the watcher for child processes.
if sys.version_info < (3, 14):

If not yet set, a :class:`~asyncio.SafeChildWatcher` object is
automatically created.
"""
if self._watcher is None:
self._init_watcher()
def get_child_watcher(self):
"""Get the watcher for child processes.
If not yet set, a :class:`~asyncio.SafeChildWatcher` object is
automatically created.
"""
if self._watcher is None:
self._init_watcher()

return self._watcher
return self._watcher

def set_child_watcher(self, watcher):
"""Set the watcher for child processes."""
if self._watcher is not None:
self._watcher.close()
def set_child_watcher(self, watcher):
"""Set the watcher for child processes."""
if self._watcher is not None:
self._watcher.close()

self._watcher = watcher
self._watcher = watcher


class CFLifecycle:
Expand Down

0 comments on commit 2142c46

Please sign in to comment.