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

Something about Download Timeout #13

Closed
ZhongJunhong opened this issue Dec 22, 2022 · 4 comments
Closed

Something about Download Timeout #13

ZhongJunhong opened this issue Dec 22, 2022 · 4 comments
Labels

Comments

@ZhongJunhong
Copy link

您好,我在下载的时候发现一些音频文件在某些情况下(可能是网络的问题)下载时间过长,而且进度条一直停滞不前,有时甚至停滞十分钟到二十分钟不等,有时候我只能手动中断使之进入下一个循环。

后来我在stackoverflow上找到一个非常非常简单的解决方案,就是在执行请求的代码前加入socket.setdefaulttimeout(30),控制socket打开的时间,比如此处我设置为30秒。

socket.setdefaulttimeout(30) 
q.retrieve_recordings(multiprocess=True, nproc=10, attempts=10, outdir="/mnt/database/xcdata/")

同时我加入一些其他设置,让代码在触发socket.timeout错误后,可以将对应的请求参数记录下来,并继续执行下一个循环。由此可以避免下载停滞的问题。当我完成所有循环以后,会将socket打开的时间再增加(比如增加到120秒),对先前记录下的请求参数再次执行。由此循环多次以将所有参数请求完毕。

https://stackoverflow.com/questions/32763720/timeout-a-file-download-with-python-urllib

希望能帮助到大家。

Hello, when I was downloading, I found that the download time of some audio files was too long under certain circumstances (may be a problem with the network), and the progress bar has been stagnant, sometimes even for ten to twenty minutes, there are Sometimes I can only manually interrupt it to enter the next cycle.

Later, I found a very, very simple solution on stackoverflow, which is to add socket.setdefaulttimeout(30) before executing the requested code to control the opening time of the socket. For example, I set it to 30 seconds here.

socket.setdefaulttimeout(30) 
q.retrieve_recordings(multiprocess=True, nproc=10, attempts=10, outdir="/mnt/database/xcdata/")

At the same time, I added some other settings so that after the code triggers the socket.timeout error, it can record the corresponding request parameters and continue to execute the next loop. This can avoid the problem of download stagnation. When I finish all the loops, I will increase the socket opening time (for example, to 120 seconds), and execute again on the previously recorded request parameters. Loop for multiple times to complete the request for all parameters.

https://stackoverflow.com/questions/32763720/timeout-a-file-download-with-python-urllib

I Hope that can help everyone.

@realzza
Copy link
Owner

realzza commented Dec 22, 2022

一些音频文件在某些情况下(可能是网络的问题)下载时间过长,而且进度条一直停滞不前,有时甚至停滞十分钟到二十分钟不等,有时候我只能手动中断使之进入下一个循环。

请提供一个代码样例复现你的问题。
一种可能的原因是,有些鸟类的recording会很长,有一小时多的,下载失败的都可以在当前目录下的failed.txt找到,且会提示bad url: .....。若下载完成后没有failed.txt且没有提示,即代表所有recording下载成功。

@realzza
Copy link
Owner

realzza commented Dec 22, 2022

为验证是否为recording长度导致,可以在定义query时加上以下三个参数重新尝试

len: recording length control parameter.
len_lt: recording length less than
len_gt: recording length greater than

@ZhongJunhong
Copy link
Author

为验证是否为recording长度导致,可以在定义query时加上以下三个参数重新尝试

len: recording length control parameter.
len_lt: recording length less than
len_gt: recording length greater than

谢谢!我先再尝试一下!

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants