Skip to content

Commit

Permalink
Merge pull request #988 from sphinx-contrib/maintenance/2024-06-22
Browse files Browse the repository at this point in the history
Maintenance (2024-06-22)
  • Loading branch information
jdknight authored Jun 22, 2024
2 parents d58ebdf + ada77b3 commit 5c16304
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
7 changes: 7 additions & 0 deletions check
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
#
# This is a helper script used to only invoke a single tox environment.
# Solely used for a quick way to run a supported environment without
# having to try to form one on the command line.

exec tox -e py312-sphinx73 $@
10 changes: 10 additions & 0 deletions sphinxcontrib/confluencebuilder/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,16 @@ def store_page(self, page_name, data, parent_id=None):

_, page = self.get_page_case_insensitive(page_name)
if not page:
# If here, the original `get_page` call failed to find
# a page with a specific name and then a retry with
# `get_page_case_insensitive` also failed again, even
# though Confluence reports the title already exists.
# At this time, this appears to be limited to users
# who use `confluence_page_search_mode` with `search`.
# There appears to be some scenarios where a Confluence
# instance will not report the existence of a deleted
# page when queried via CQL, which prevents us from
# reviving a page from the dead.
raise

if self.onlynew:
Expand Down
14 changes: 7 additions & 7 deletions sphinxcontrib/confluencebuilder/rest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright Sphinx Confluence Builder Contributors (AUTHORS)

from functools import wraps
from email.utils import mktime_tz
from email.utils import parsedate_tz
from functools import wraps
from requests.adapters import HTTPAdapter
from sphinx.util.logging import skip_warningiserror
from sphinxcontrib.confluencebuilder.debug import PublishDebug
from sphinxcontrib.confluencebuilder.exceptions import ConfluenceAuthenticationFailedUrlError
Expand All @@ -21,7 +22,6 @@
from sphinxcontrib.confluencebuilder.retry import API_RETRY_ERRORS
from sphinxcontrib.confluencebuilder.std.confluence import NOCHECK
from sphinxcontrib.confluencebuilder.std.confluence import RSP_HEADER_RETRY_AFTER
from requests.adapters import HTTPAdapter
import inspect
import json
import math
Expand All @@ -31,7 +31,6 @@
import time



# the maximum times a request will be retried until stopping (rate limiting)
RATE_LIMITED_MAX_RETRIES = 5

Expand Down Expand Up @@ -182,8 +181,8 @@ def _wrapper(self, *args, **kwargs):
if attempt > RATE_LIMITED_MAX_RETRIES:
raise

# determine the amount of delay to wait again -- either from the
# provided delay (if any) or exponential backoff
# determine the amount of delay to wait again -- either
# from the provided delay (if any) or exponential backoff
if self.next_delay:
delay = self.next_delay
self.next_delay = None
Expand All @@ -197,8 +196,9 @@ def _wrapper(self, *args, **kwargs):
delay += random.uniform(0.3, 1.3) # noqa: S311

# wait the calculated delay before retrying again
logger.warn('rate-limit response detected; '
f'waiting {math.ceil(delay)} seconds...')
with skip_warningiserror():
logger.warn('rate-limit response detected; '
f'waiting {math.ceil(delay)} seconds...')
time.sleep(delay)
self.last_retry = delay
attempt += 1
Expand Down

0 comments on commit 5c16304

Please sign in to comment.