-
Notifications
You must be signed in to change notification settings - Fork 36
Add support for python 3.14 #744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Eijebong
wants to merge
4
commits into
mozilla-releng:main
Choose a base branch
from
Eijebong:py314
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| """GitHub helper functions.""" | ||
|
|
||
| import asyncio | ||
| import logging | ||
| import re | ||
|
|
||
| from aiomemoizettl import memoize_ttl | ||
| from github3 import GitHub | ||
| from github3.exceptions import GitHubException | ||
|
|
||
|
|
@@ -136,24 +136,36 @@ async def has_commit_landed_on_repository(self, context, revision): | |
| return html_text != "" | ||
|
|
||
|
|
||
| # TODO Use memoize_ttl() as decorator once https://github.com/michalc/aiomemoizettl/issues/2 is done | ||
| async def _fetch_github_branch_commits_data_helper(context, repo_html_url, revision): | ||
| url = "/".join((repo_html_url.rstrip("/"), "branch_commits", revision)) | ||
| log.info('Cache does not exist for URL "{}" (in this context), fetching it...'.format(url)) | ||
| html_text = await retry_request(context, url) | ||
| return html_text.strip() | ||
| _BRANCH_COMMITS_CACHE_TTL_IN_SECONDS = 10 * 60 # 10 minutes | ||
| _BRANCH_COMMITS_CACHE = {} | ||
|
|
||
|
|
||
| # XXX memoize_ttl() uses all function parameters to create a key that stores its cache. | ||
| # This means new contexts cannot use the memoized value, even though they're calling the same | ||
| # repo and revision. jlorenzo tried to take the context out of the memoize_ttl() call, but | ||
| # whenever the cache is invalidated, request() doesn't work anymore because the session carried | ||
| # by the context has been long closed. | ||
| # Therefore, the defined TTL has 2 purposes: | ||
| # a. it memoizes calls for the time of a single cot_verify() run | ||
| # b. it clears the cache automatically, so we don't have to manually invalidate it. | ||
| _BRANCH_COMMITS_CACHE_TTL_IN_SECONDS = 10 * 60 # 10 minutes | ||
| _fetch_github_branch_commits_data = memoize_ttl(_fetch_github_branch_commits_data_helper, get_ttl=lambda _: _BRANCH_COMMITS_CACHE_TTL_IN_SECONDS) | ||
| async def _fetch_github_branch_commits_data(context, repo_html_url, revision): | ||
| cache_key = (id(context), repo_html_url, revision) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the previous comment we don't actually want the context in here? Probably safer to keep it at least for this commit, but might still warrant a comment? |
||
|
|
||
| if cache_key in _BRANCH_COMMITS_CACHE: | ||
| return await _BRANCH_COMMITS_CACHE[cache_key] | ||
|
|
||
| future = asyncio.get_running_loop().create_future() | ||
| _BRANCH_COMMITS_CACHE[cache_key] = future | ||
|
|
||
| try: | ||
| url = "/".join((repo_html_url.rstrip("/"), "branch_commits", revision)) | ||
| html_text = await retry_request(context, url) | ||
| result = html_text.strip() | ||
| future.set_result(result) | ||
| asyncio.get_running_loop().call_later( | ||
| _BRANCH_COMMITS_CACHE_TTL_IN_SECONDS, | ||
| _BRANCH_COMMITS_CACHE.pop, | ||
| cache_key, | ||
| None, | ||
| ) | ||
| except BaseException as e: | ||
| _BRANCH_COMMITS_CACHE.pop(cache_key, None) | ||
| future.set_exception(e) | ||
| raise | ||
|
|
||
| return result | ||
|
|
||
|
|
||
| def is_github_url(url): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1