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

timeout function #355

Open
NannoSilver opened this issue Nov 24, 2024 · 0 comments
Open

timeout function #355

NannoSilver opened this issue Nov 24, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@NannoSilver
Copy link
Contributor

An idea for a future improvement.
Years ago something similar has been suggested by somebody else for pytube.

Simple operations sometimes take a lot of time to be completed. In many cases is easier just cancel and run again, to get the result very fast.

Nowadays I am using the library func-timeout to limit the execution time for a given operation and backoff to retry. This works, but is not very convenient as it needs additional functions to keep the processing under control.

timeout is supported by requests, so likely not very hard to implement.

Here an example of how the code with timeout can be:

from pytubefix import YouTube

youtube_episode_id = '3p6DEyF5LZM'

url = f'https://www.youtube.com/watch?v={youtube_episode_id}'
yt = YouTube(url, timeout=5)

print(yt.title)
print(yt.author)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: enhancement
Development

No branches or pull requests

1 participant