Skip to content

Commit

Permalink
[added] Added a sane time limit for the Kobo API connections, they we…
Browse files Browse the repository at this point in the history
…re hanging forever.
  • Loading branch information
TnS-hun committed Apr 11, 2022
1 parent 202b33b commit 8c04f13
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kobo-book-downloader/Kobo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def ReauthenticationHook( r, *args, **kwargs ):

return _r

class SessionWithTimeOut( requests.Session ):
def request( self, method, url, **kwargs ):
if "timeout" not in kwargs:
kwargs[ "timeout" ] = 30 # 30 seconds
return super().request( method, url, **kwargs )

class Kobo:
Affiliate = "Kobo"
ApplicationVersion = "8.11.24971"
Expand All @@ -51,7 +57,7 @@ class Kobo:

def __init__( self ):
self.InitializationSettings = {}
self.Session = requests.session()
self.Session = SessionWithTimeOut()

# This could be added to the session but then we would need to add { "Authorization": None } headers to all other
# functions that doesn't need authorization.
Expand Down

0 comments on commit 8c04f13

Please sign in to comment.