Skip to content

Commit

Permalink
Merge pull request #7268 from p12tic/twisted-upgrade
Browse files Browse the repository at this point in the history
Fix support for Twisted 23.10
  • Loading branch information
p12tic committed Dec 17, 2023
2 parents 4cbad49 + ad188e6 commit 2dd52f7
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions .bbtravis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ matrix:
# include "ci" string into the name of the status that is eventually submitted to Github, so
# that the codecov.io service would wait until this build is finished before creating report.
- env: PYTHON=3.9 TWISTED=18.7.0 SQLALCHEMY=latest NUM_CPU=2 TESTS=trial
- env: PYTHON=3.9 TWISTED=22.4.0 SQLALCHEMY=latest NUM_CPU=2 TESTS=trial
- env: PYTHON=3.8 TWISTED=latest SQLALCHEMY=latest NUM_CPU=2 TESTS=ci/coverage
- env: PYTHON=3.9 TWISTED=latest SQLALCHEMY=latest NUM_CPU=2 TESTS=trial
- env: PYTHON=3.10 TWISTED=latest SQLALCHEMY=latest NUM_CPU=2 TESTS=trial
Expand Down
7 changes: 6 additions & 1 deletion master/buildbot/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ def deferred_await(self):
# if a deferred is awaited from a asyncio loop context, we must return
# the future wrapper, but if it is awaited from normal twisted loop
# we must return self.
if isinstance(asyncio.get_event_loop(), AsyncIOLoopWithTwisted):
try:
loop = asyncio.get_event_loop()
except RuntimeError:
return self

if isinstance(loop, AsyncIOLoopWithTwisted):
return self.asFuture(asyncio.get_event_loop())
return self

Expand Down
7 changes: 7 additions & 0 deletions master/buildbot/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,10 @@
# boto3 shows this warning when on old Python
warnings.filterwarnings('ignore', ".*Boto3 will no longer support Python .*",
category=Warning)

# autobahn is not updated for Twisted 22.04 and newer
warnings.filterwarnings("ignore", "twisted.web.resource.NoResource was deprecated in",
category=DeprecationWarning)

# Buildbot shows this warning after upgrading to Twisted 23.10
warnings.filterwarnings('ignore', ".*unclosed event loop.*", category=Warning)
10 changes: 9 additions & 1 deletion master/buildbot/www/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
from binascii import hexlify

import jwt
from packaging.version import parse as parse_version

import twisted
from twisted.application import strports
from twisted.cred.portal import IRealm
from twisted.cred.portal import Portal
Expand Down Expand Up @@ -275,7 +277,13 @@ def refresh_base_plugin_name(self, new_config):
def configPlugins(self, root, new_config):
plugin_root = root
if self.base_plugin_name == 'base_react':
plugin_root = resource.NoResource()
current_version = parse_version(twisted.__version__)
if current_version < parse_version("22.10.0"):
from twisted.web.resource import NoResource
plugin_root = NoResource()
else:
from twisted.web.pages import notFound
plugin_root = notFound()
root.putChild(b"plugins", plugin_root)

known_plugins = set(new_config.www.get('plugins', {})) | set([self.base_plugin_name])
Expand Down
2 changes: 1 addition & 1 deletion master/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def define_plugin_entries(groups):
if not py_38:
raise RuntimeError("Buildbot master requires at least Python-3.8")

twisted_ver = ">= 18.7.0, <=22.10.0"
twisted_ver = ">= 18.7.0, <=23.10.0"

bundle_version = version.split("-")[0]

Expand Down
1 change: 1 addition & 0 deletions newsfragments/allow-twisted-dep-23-10.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix support for Twisted 23.10
2 changes: 1 addition & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ tomli==2.0.1
tomlkit==0.12.3
towncrier==21.9.0
treq==22.2.0
Twisted==22.4.0
Twisted==23.10.0
txaio==23.1.1
txrequests==0.9.6
types-PyYAML==6.0.12.12
Expand Down
2 changes: 1 addition & 1 deletion requirements-ciworker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PyHamcrest==1.9.0 # pyup: ignore
psutil==5.9.6
pycparser==2.21; python_version >= "3.6"
six==1.16.0
Twisted==22.4.0; python_version >= "3.6"
Twisted==23.10.0; python_version >= "3.6"
Twisted==20.3.0; python_version < "3.6" # pyup: ignore
txaio==23.1.1; python_version >= "3.6"
typing-extensions==4.8.0; python_version >= "3.7"
Expand Down

0 comments on commit 2dd52f7

Please sign in to comment.