From 98624f3d6a32882d5fb2283fa61690226e81299e Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 12 Jan 2023 09:53:07 -0500 Subject: [PATCH 1/7] Attempt to workaround for 3960. --- .github/workflows/ci.yml | 9 +++++++++ newsfragments/3960.minor | 0 2 files changed, 9 insertions(+) create mode 100644 newsfragments/3960.minor diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80b312008..2a8f5246e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,8 +86,17 @@ jobs: run: python misc/build_helpers/show-tool-versions.py - name: Run tox for corresponding Python version + if: ${{ !contains(matrix.os, 'windows') }} run: python -m tox + # On Windows, a non-blocking pipe might respond (when emulating Unix-y + # API) with ENOSPC to indicate buffer full. Trial doesn't handle this + # well. So, we pipe the output through Get-Content (similar to piping + # through cat) to make buffer handling someone else's problem. + - name: Run tox for corresponding Python version + if: ${{ contains(matrix.os, 'windows') }} + run: python -m tox | Get-Content + - name: Upload eliot.log uses: actions/upload-artifact@v3 with: diff --git a/newsfragments/3960.minor b/newsfragments/3960.minor new file mode 100644 index 000000000..e69de29bb From e142f051b497124cb8828106242d14cb46643431 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 12 Jan 2023 10:01:09 -0500 Subject: [PATCH 2/7] Cats solve problems, right? --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a8f5246e..1b8ab0d57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,11 +91,11 @@ jobs: # On Windows, a non-blocking pipe might respond (when emulating Unix-y # API) with ENOSPC to indicate buffer full. Trial doesn't handle this - # well. So, we pipe the output through Get-Content (similar to piping - # through cat) to make buffer handling someone else's problem. + # well. So, we pipe the output through cat to make buffer handling someone + # else's problem. - name: Run tox for corresponding Python version if: ${{ contains(matrix.os, 'windows') }} - run: python -m tox | Get-Content + run: python -m tox | cat - name: Upload eliot.log uses: actions/upload-artifact@v3 From dd89ca6d4f2738f92534f0b33da2a365b9f30016 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 12 Jan 2023 10:36:39 -0500 Subject: [PATCH 3/7] Another approach. --- .github/workflows/ci.yml | 8 ++++--- misc/windows-enospc/passthrough.py | 38 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 misc/windows-enospc/passthrough.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b8ab0d57..1eb12bdd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,11 +91,13 @@ jobs: # On Windows, a non-blocking pipe might respond (when emulating Unix-y # API) with ENOSPC to indicate buffer full. Trial doesn't handle this - # well. So, we pipe the output through cat to make buffer handling someone - # else's problem. + # well. So, we pipe the output through pipethrough that will hopefully be + # able to do the right thing by using Windows APIs. - name: Run tox for corresponding Python version if: ${{ contains(matrix.os, 'windows') }} - run: python -m tox | cat + run: | + pip install twisted + python -m tox | python misc/windows-enospc/passthrough.py - name: Upload eliot.log uses: actions/upload-artifact@v3 diff --git a/misc/windows-enospc/passthrough.py b/misc/windows-enospc/passthrough.py new file mode 100644 index 000000000..6be3d7dbe --- /dev/null +++ b/misc/windows-enospc/passthrough.py @@ -0,0 +1,38 @@ +""" +Writing to non-blocking pipe can result in ENOSPC when using Unix APIs on +Windows. So, this program passes through data from stdin to stdout, using +Windows APIs instead of Unix-y APIs. +""" + +import sys + +from twisted.internet.stdio import StandardIO +from twisted.internet import reactor +from twisted.internet.protocol import Protocol +from twisted.internet.interfaces import IHalfCloseableProtocol +from twisted.internet.error import ReactorNotRunning +from zope.interface import implementer + +@implementer(IHalfCloseableProtocol) +class Passthrough(Protocol): + def readConnectionLost(self): + self.transport.loseConnection() + + def writeConnectionLost(self): + try: + reactor.stop() + except ReactorNotRunning: + pass + + def dataReceived(self, data): + self.transport.write(data) + + def connectionLost(self, reason): + try: + reactor.stop() + except ReactorNotRunning: + pass + + +std = StandardIO(Passthrough()) +reactor.run() From e997bb9c398d191c28c7a82840a2df3bbbb657e9 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 12 Jan 2023 10:39:50 -0500 Subject: [PATCH 4/7] Also need pywin32. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1eb12bdd5..0f8040e96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,7 +96,7 @@ jobs: - name: Run tox for corresponding Python version if: ${{ contains(matrix.os, 'windows') }} run: | - pip install twisted + pip install twisted pywin32 python -m tox | python misc/windows-enospc/passthrough.py - name: Upload eliot.log From ee5ad549fed7150d2a6782ca4409b27c5821d546 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 12 Jan 2023 11:12:00 -0500 Subject: [PATCH 5/7] Clarify. --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f8040e96..011bfc1ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,8 +91,9 @@ jobs: # On Windows, a non-blocking pipe might respond (when emulating Unix-y # API) with ENOSPC to indicate buffer full. Trial doesn't handle this - # well. So, we pipe the output through pipethrough that will hopefully be - # able to do the right thing by using Windows APIs. + # well, so it breaks test runs. To attempt to solve this, we pipe the + # output through pipethrough that will hopefully be able to do the right + # thing by using Windows APIs. - name: Run tox for corresponding Python version if: ${{ contains(matrix.os, 'windows') }} run: | From a765d8a35b8d0bdbe6163585dcdd96f4d6f7eddf Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 12 Jan 2023 11:18:05 -0500 Subject: [PATCH 6/7] Unused. --- misc/windows-enospc/passthrough.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/misc/windows-enospc/passthrough.py b/misc/windows-enospc/passthrough.py index 6be3d7dbe..1d4cd48bb 100644 --- a/misc/windows-enospc/passthrough.py +++ b/misc/windows-enospc/passthrough.py @@ -4,8 +4,6 @@ Windows. So, this program passes through data from stdin to stdout, using Windows APIs instead of Unix-y APIs. """ -import sys - from twisted.internet.stdio import StandardIO from twisted.internet import reactor from twisted.internet.protocol import Protocol From e64c6b02e6370290a9c6d9ca17257b2e736f693a Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Fri, 13 Jan 2023 10:29:22 -0500 Subject: [PATCH 7/7] Fix a typo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 011bfc1ea..4d67f09bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: # On Windows, a non-blocking pipe might respond (when emulating Unix-y # API) with ENOSPC to indicate buffer full. Trial doesn't handle this # well, so it breaks test runs. To attempt to solve this, we pipe the - # output through pipethrough that will hopefully be able to do the right + # output through passthrough.py that will hopefully be able to do the right # thing by using Windows APIs. - name: Run tox for corresponding Python version if: ${{ contains(matrix.os, 'windows') }}