Skip to content

Commit

Permalink
Add Configurable KALTURA_TIMEOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
angrave committed Jan 27, 2024
1 parent 44a48d0 commit 2b2073e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions PythonRpcServer/kaltura.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
KALTURA_PARTNER_ID = int(os.getenv('KALTURA_PARTNER_ID', default=0))
KALTURA_TOKEN_ID = os.getenv('KALTURA_TOKEN_ID', default=None)
KATLURA_APP_TOKEN = os.getenv('KALTURA_APP_TOKEN', default=None)

KALTURA_TIMEOUT= int( os.getenv('KALTURA_TIMEOUT', default=30))

# Examples of Playlists URLs the user is likely to see-
# Playlist 1_eilnj5er is Angrave's short set of example vidos
Expand Down Expand Up @@ -181,7 +181,7 @@ def getMediaInfosForKalturaChannel(self, partnerInfo, channelId):
return self.getSensibleMediaInfos(res)

def downloadLecture(self, url):
filePath, extension = download_file(url)
filePath, extension = download_file(url, timeout=KALTURA_TIMEOUT)
return filePath, extension

#Exxpects
Expand Down
4 changes: 2 additions & 2 deletions PythonRpcServer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def extension_from_magic_bytes(filepath):
# Filepath and cookies may be specified
# Returns a two tuple, [filepath, extension]
# An appropriate Extension is guessed based on the mimetype in the 'content-type' response header
def download_file(url, filepath=None, cookies=None):
def download_file(url, filepath=None, cookies=None, timeout=60):
# NOTE the stream=True parameter below
if not filepath:
filepath = getTmpFile()
extension = None
with requests.get(url, stream=True, allow_redirects=True, cookies=cookies) as r:
with requests.get(url, stream=True, allow_redirects=True, cookies=cookies, timeout=timeout) as r:


r.raise_for_status()
Expand Down

0 comments on commit 2b2073e

Please sign in to comment.