Skip to content

Commit

Permalink
fix #1 missing HTTP timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
boramalper committed May 31, 2020
1 parent 4aa2590 commit d804abd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions nm_feedfinder/nm_feedfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from bs4 import BeautifulSoup
import requests

TIMEOUT = 3

def feeds(address: str) -> List[str]:
# Python dictionaries are ordered so this serves us as an ordered set.
Expand Down Expand Up @@ -46,7 +47,7 @@ def find_links(sesh: requests.Session, url: ParseResult) -> List[str]:
links = []

try:
response = sesh.get(urlunparse(url), timeout=3)
response = sesh.get(urlunparse(url), timeout=TIMEOUT)
response.raise_for_status()
except requests.exceptions.RequestException:
return []
Expand Down Expand Up @@ -130,7 +131,7 @@ def try_hrefs(sesh: requests.Session, url: ParseResult, soup: BeautifulSoup) ->

def could_be_feed(sesh: requests.Session, url: str) -> bool:
try:
response = sesh.get(url)
response = sesh.get(url, timeout=TIMEOUT)
response.raise_for_status()
except requests.exceptions.RequestException:
return False
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name='nm_feedfinder',
packages=['nm_feedfinder'],
version='0.1',
version='0.2',
license='ISC',
description='Find Atom/RSS links of a website given a URL',
author='newsmail.today',
Expand Down

0 comments on commit d804abd

Please sign in to comment.