|
11 | 11 | from enum import Enum |
12 | 12 | from typing import Callable, Iterable, List, Optional, Protocol, Union |
13 | 13 |
|
14 | | -import backoff |
15 | 14 | import recurring_ical_events |
16 | 15 | from dotenv import load_dotenv |
17 | 16 | import icalendar |
|
25 | 24 |
|
26 | 25 | _log = logging.getLogger(__file__) |
27 | 26 |
|
28 | | -_DEFAULT_DISPLAY = " " * 8 + "." |
29 | | - |
30 | 27 |
|
31 | 28 | class Uninitialized(Enum): |
32 | 29 | """Indicates a missing value.""" |
@@ -95,13 +92,6 @@ def fetch(self) -> icalendar.cal.Component: |
95 | 92 | calendar = icalendar.Calendar.from_ical(ics) |
96 | 93 | return calendar |
97 | 94 |
|
98 | | - @backoff.on_exception( |
99 | | - backoff.expo, |
100 | | - RequestException, |
101 | | - max_tries=5, |
102 | | - logger=_log, |
103 | | - backoff_log_level=logging.WARNING, |
104 | | - ) |
105 | 95 | def _fetch_remote(self) -> str: |
106 | 96 | _log.info("Fetching ics file from remote url %r", self._ics_url) |
107 | 97 | return self._session.get(self._ics_url).text |
@@ -294,6 +284,7 @@ def run(self) -> None: |
294 | 284 | def poll(self) -> None: |
295 | 285 | try: |
296 | 286 | self._calendar = self._calendar_queue.get(timeout=self._poll_interval) |
| 287 | + _log.info("Loaded new calendar for RelevantMarkExtractor") |
297 | 288 | except queue.Empty: |
298 | 289 | pass |
299 | 290 |
|
@@ -416,18 +407,23 @@ def run(self) -> None: |
416 | 407 | calendar_queue = queue.Queue(1) |
417 | 408 | relevant_mark_queue = queue.Queue(1) |
418 | 409 |
|
419 | | - def calendar_fetcher_loop() -> None: |
420 | | - _log.debug("Fetching calendar") |
421 | | - calendar = self._calendar_fetcher.fetch() |
| 410 | + def calendar_fetcher_poll() -> None: |
| 411 | + _log.info("Fetching calendar") |
| 412 | + try: |
| 413 | + calendar = self._calendar_fetcher.fetch() |
| 414 | + except RequestException: |
| 415 | + _log.exception("Fetching calendar failed, no calendar added to queue") |
| 416 | + return |
| 417 | + |
422 | 418 | try: |
423 | 419 | calendar_queue.put(calendar) |
424 | 420 | except queue.Full: |
425 | 421 | pass |
426 | | - _log.debug("Fetched calendar") |
| 422 | + _log.info("Fetched calendar") |
427 | 423 |
|
428 | 424 | def calender_fetcher_run() -> None: |
429 | 425 | poll_until_shutdown( |
430 | | - calendar_fetcher_loop, |
| 426 | + calendar_fetcher_poll, |
431 | 427 | self._calendar_fetch_interval, |
432 | 428 | self._shutdown_event, |
433 | 429 | ) |
|
0 commit comments