Coverage for daklib/btsutils.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2026-08-03 16:46 +0000

1# SPDX-License-Identifier: GPL-2.0-or-later 

2# © 2026, Ansgar 🙀 <ansgar@debian.org> 

3 

4""" 

5Access to the Debian bug tracking system 

6 

7Retry-wrapped aliases of the C{debianbts} functions so that all BTS access 

8retries transient network failures. The queries are read-only and 

9idempotent, so retrying is safe. 

10""" 

11 

12import logging 

13 

14import debianbts as _bts 

15from tenacity import ( 

16 before_sleep_log, 

17 retry, 

18 retry_if_exception_type, 

19 stop_after_attempt, 

20 wait_exponential, 

21) 

22 

23log = logging.getLogger(__name__) 

24 

25# debianbts talks to the BTS over the network (urllib/SOAP). All transient 

26# transport failures it raises are OSError subclasses (URLError, HTTPError, 

27# TimeoutError, ConnectionError); SOAP application faults are RuntimeError 

28# and are not retried. 

29_bts_retry = retry( 

30 stop=stop_after_attempt(5), 

31 wait=wait_exponential(multiplier=1, max=30), 

32 retry=retry_if_exception_type(OSError), 

33 reraise=True, 

34 before_sleep=before_sleep_log(log, logging.WARNING), 

35) 

36 

37get_bugs = _bts_retry(_bts.get_bugs) 

38get_status = _bts_retry(_bts.get_status) 

39get_usertag = _bts_retry(_bts.get_usertag)