Skip to content

Commit 8d615df

Browse files
author
Jack Pugmire
committed
Added support for httplib2 timeouts.
1 parent ca91070 commit 8d615df

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pytvdbapi/api.py

100644100755
+5-1
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,10 @@ class TVDB(object):
593593
case insensitive manner. If set to False, the default, all
594594
attributes will be case sensitive and retain the same casing
595595
as provided by `thetvdb.com <http://thetvdb.com>`_.
596+
597+
* **timeout** (default=None) When set to a number, will cause the http
598+
request to timeout after that number of seconds.
599+
596600
"""
597601

598602
@unicode_arguments
@@ -612,7 +616,7 @@ def __init__(self, api_key, **kwargs):
612616
self.config['ignore_case'] = kwargs.get('ignore_case', False)
613617

614618
# Create the loader object to use
615-
self.loader = Loader(self.config['cache_dir'])
619+
self.loader = Loader(self.config['cache_dir'], timeout=kwargs.get('timeout', None))
616620

617621
# Create the list of available mirrors
618622
tree = generate_tree(self.loader.load(mirrors.format(**self.config)))

pytvdbapi/loader.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ class Loader(object):
4141
Uses httplib2 to do the heavy lifting.
4242
"""
4343

44-
def __init__(self, cache_path):
45-
self.http = httplib2.Http(cache=os.path.abspath(cache_path))
44+
def __init__(self, cache_path, timeout=None):
45+
self.http = httplib2.Http(cache=os.path.abspath(cache_path),
46+
timeout=timeout)
4647

4748
def load(self, url, cache=True):
4849
"""

0 commit comments

Comments
 (0)