diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ce70dcf90ba..a585723979d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -171,6 +171,16 @@ jobs: # select a reactor. trial-args: '--reactor=select' + # Windows, newest Python supported version with gi reactor. + # This needs a python version supported by Deluge GTK distribution. + - python-version: '3.10' + runs-on: 'windows-2022' + tox-env: 'alldeps-withcov-winghagi-windows' + job-name: 'win-default-tests-gi' + # Distributed trial is not yet suported on Windows. + # TOOO; set selector to gi once GI support is available. + trial-args: '--reactor=select' + # Windows, newest Python supported version with iocp reactor. - python-version: '3.12' runs-on: 'windows-2022' @@ -247,7 +257,7 @@ jobs: # Make sure the matrix is defined in such a way that this is triggered # only on Linux. - - name: Install GTK system deps + - name: Install GTK system deps on Linux if: matrix.platform-deps == 'gtk-platform' run: | # *-dev dependencies are for pygobject @@ -261,6 +271,19 @@ jobs: gir1.2-gtk-3.0 \ xvfb + # Make sure the matrix is defined in such a way that this is triggered + # only on Linux. + - name: Install GTK system deps on windows + if: matrix.tox-env == 'alldeps-withcov-winghagi-windows' + shell: pwsh + run: | + $WebClient = New-Object System.Net.WebClient + $WebClient.DownloadFile("https://github.com/deluge-torrent/gvsbuild-release/releases/download/latest/gvsbuild-py3.10-vs16-x64.zip","C:\GTK.zip") + 7z x C:\GTK.zip -oc:\GTK + echo "C:\GTK\release\lib" | Out-File -FilePath $env:GITHUB_PATH -Append + echo "C:\GTK\release\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + echo "C:\GTK\release" | Out-File -FilePath $env:GITHUB_PATH -Append + - name: Test run: | ${{ matrix.tox-wrapper }} tox ${{ matrix.trial-target }} diff --git a/src/twisted/internet/_signals.py b/src/twisted/internet/_signals.py index 18793bfbba2..a1d4fc53e74 100644 --- a/src/twisted/internet/_signals.py +++ b/src/twisted/internet/_signals.py @@ -49,9 +49,15 @@ from twisted.internet.interfaces import IReadDescriptor from twisted.python import failure, log, util from twisted.python.runtime import platformType +from . import fdesc if platformType == "posix": - from . import fdesc, process + from .process import reapAllProcesses +else: + + def reapAllProcesses() -> None: + "Do nothing on Windows." + SignalHandler: TypeAlias = Callable[[int, Optional[FrameType]], None] @@ -232,7 +238,7 @@ def install(self) -> None: # This should only happen if someone used spawnProcess # before calling reactor.run (and the process also exited # already). - process.reapAllProcesses() + reapAllProcesses() def uninstall(self) -> None: """ @@ -411,7 +417,7 @@ def wakeUp(self): if platformType == "posix": _Waker = _UnixWaker else: - # Primarily Windows and Jython. + # Windows, and possibly other platforms without signals support _Waker = _SocketWaker # type: ignore[misc,assignment] @@ -442,4 +448,4 @@ def doRead(self) -> None: method. """ super().doRead() - process.reapAllProcesses() + reapAllProcesses() diff --git a/src/twisted/newsfragments/11987.bugfix b/src/twisted/newsfragments/11987.bugfix new file mode 100644 index 00000000000..516a38c4eb6 --- /dev/null +++ b/src/twisted/newsfragments/11987.bugfix @@ -0,0 +1 @@ +gi and gtk reactors now work again on Windows. diff --git a/tox.ini b/tox.ini index 9f5e9613c07..0315ce89a11 100644 --- a/tox.ini +++ b/tox.ini @@ -120,6 +120,9 @@ commands = posix: python -c "print('Running on POSIX (no special dependencies)')" + ; Install based on the the local GTK based on GitHub Actions and Deluge. + winghagi: python -m pip install --no-index --find-links="C:\GTK\release\python" PyGObject + ; Run tests without wrapping them using coverage. nocov: python -m twisted.trial --temp-directory={envtmpdir}/_trial_temp --reporter={env:TRIAL_REPORTER:verbose} {env:TRIAL_ARGS:-j8} {posargs:twisted}