frostming / unearth

A utility to fetch and download python packages
https://unearth.readthedocs.io
MIT License
142 stars 18 forks source link

Add a default timeout to requests #80

Closed logut closed 10 months ago

logut commented 1 year ago

Is your feature request related to a problem? Please describe. When working in an environment without direct internet access, it's often hard to recognize why the program hangs indefinitely.

Describe the solution you'd like I would like the call to timeout after a short period.

Describe alternatives you've considered

Additional context https://requests.readthedocs.io/en/latest/user/advanced/#timeouts Two values for timeouts are possible with requests : connect and read. Maybe we could keep the connect to a short value like 5s and the read to longer like 30s, 60s or even None.

Timeouts can be implemented on each session.get() calls or can be implemented at the session level directly with an adapter : https://stackoverflow.com/a/62044100/6507969. This method would have the advantage of setting default timeout for other projects using PyPISession directly.