Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Configurable KALTURA_TIMEOUT #468

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading