diff --git a/CHANGELOG.md b/CHANGELOG.md index ad5760d..4776d54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Changed +- automatic retries now apply to all errors instead of just 429 HTTP responses +- pinned pyyaml 6.0.1 to avoid issues with cython 3 + ## 2.2.1 - 2023-07-17 ### Fixed - Local section links are no longer rendered as broken relative links (e.g. `[this section](#section-header)`) diff --git a/md2cf/__main__.py b/md2cf/__main__.py index 9f78287..7db41fb 100644 --- a/md2cf/__main__.py +++ b/md2cf/__main__.py @@ -249,6 +249,14 @@ def get_parser(): help="markdown files or directories to upload to Confluence. Empty for stdin", nargs="*", ) + parser.add_argument( + "--max-retries", + action="store", + dest="max_retries", + type=int, + default=4, + help="number of retry attempts if any API call fails", + ) return parser @@ -297,6 +305,7 @@ def main(): password=args.password, token=args.token, verify=not args.insecure, + max_retries=args.max_retries, ) if (args.title or args.page_id) and ( @@ -380,6 +389,7 @@ def main(): something_went_wrong = False error = None tui = Md2cfTUI(pages_to_upload) + with tui: space_info = confluence.get_space( args.space, additional_expansions=["homepage"] diff --git a/md2cf/api.py b/md2cf/api.py index dd2a0cb..54ba44a 100644 --- a/md2cf/api.py +++ b/md2cf/api.py @@ -25,7 +25,9 @@ def __init__(self, kwargs=None): class MinimalConfluence: - def __init__(self, host, username=None, password=None, token=None, verify=True): + def __init__( + self, host, username=None, password=None, token=None, verify=True, max_retries=4 + ): if token is None: if username is None and password is None: raise ValueError( @@ -47,10 +49,10 @@ def __init__(self, host, username=None, password=None, token=None, verify=True): adapter = requests.adapters.HTTPAdapter( max_retries=urllib3.Retry( - total=4, + total=max_retries, backoff_factor=1, respect_retry_after_header=True, - status_forcelist=[429], + allowed_methods=None, ) ) self.api.mount("http://", adapter) diff --git a/setup.py b/setup.py index 1ceecc7..d26eb3c 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ "mistune==0.8.4", "chardet==5.1.0", "requests==2.31.0", - "PyYAML==6.0", + "PyYAML==6.0.1", "gitignorefile==1.1.2", ], python_requires=">=3.7",