Skip to content

Commit

Permalink
Merge pull request #260 from pyupio/fix/catching-request-exceptions
Browse files Browse the repository at this point in the history
Catching exceptions when requests are made for an unavailable resource.
  • Loading branch information
yeisonvargasf committed Nov 8, 2022
2 parents e4ae149 + 389c6e0 commit 1cc5354
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelogs/changelogs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import functools
import subprocess
from tempfile import mkdtemp
import imp
Expand Down Expand Up @@ -156,6 +157,9 @@ def get(name, vendor="pypi", functions={}, _depth=0):
"""
fns = _bootstrap_functions(name=name, vendor=vendor, functions=functions)
session = Session()
session.request = functools.partial(session.request, timeout=10)
session.max_redirects = 3

# get meta data for the given package and use this metadata to
# find urls pointing to a possible changelog
data = fns["get_metadata"](session=session, name=name)
Expand Down
4 changes: 2 additions & 2 deletions changelogs/finder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import validators
from lxml import etree
from requests import ConnectionError
from requests import ConnectionError, RequestException
import re
import logging

Expand Down Expand Up @@ -85,7 +85,7 @@ def find_repo_urls(session, name, candidates):
if link:
logger.debug("Found repo URL {}".format(link))
yield link
except ConnectionError:
except (ConnectionError, RequestException):
# we really don't care about connection errors here.
# A lot of project pages are simply down because the project is no longer maintained
pass
Expand Down

0 comments on commit 1cc5354

Please sign in to comment.