Skip to content

Commit

Permalink
[plugin/script] add timeout: 20.0s
Browse files Browse the repository at this point in the history
  • Loading branch information
grqx committed Dec 27, 2024
1 parent 545c4c1 commit 54b9255
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugin/yt_dlp_plugins/extractor/getpot_bgutil_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _get_pot(self, client: str, ydl: YoutubeDL, visitor_data=None, data_sync_id=
'data_sync_id': data_sync_id,
'proxy': proxy,
}).encode(), headers={'Content-Type': 'application/json'},
extensions={'timeout': 20}, proxies={'all': None}))
extensions={'timeout': 20.0}, proxies={'all': None}))
except Exception as e:
raise RequestError(
f'Error reaching POST /get_pot (caused by {e!s})') from e
Expand Down
8 changes: 6 additions & 2 deletions plugin/yt_dlp_plugins/extractor/getpot_bgutil_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ def _get_pot(self, client: str, ydl: YoutubeDL, visitor_data=None, data_sync_id=

try:
stdout, stderr, returncode = Popen.run(
command_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
command_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
timeout=20.0)
except subprocess.TimeoutExpired as e:
raise RequestError(
f'_get_pot_via_script failed: Timeout expired when trying to run script (caused by {e!r})')
except Exception as e:
raise RequestError(
f'_get_pot_via_script failed: Unable to run script (caused by {e!s})') from e
f'_get_pot_via_script failed: Unable to run script (caused by {e!r})') from e

msg = f'stdout:\n{stdout.strip()}'
if stderr.strip(): # Empty strings are falsy
Expand Down

0 comments on commit 54b9255

Please sign in to comment.