This is an archive of the discontinued LLVM Phabricator instance.

[llvmlab] Add timeout and retries for fetching builds.
ClosedPublic

Authored by vsapsai on Sep 26 2017, 10:06 AM.

Details

Summary

In case of network problems, time out after 5 seconds instead of relying on OS
to close the connection which can take more than 20 minutes. Timeout value is
measured between successfully transmitted packets, not for entire transaction.
So we don't require big files to be downloaded in 5 seconds but we require not
to get stuck for more than 5 seconds.

Diff Detail

Repository
rL LLVM

Event Timeline

vsapsai created this revision.Sep 26 2017, 10:06 AM
JDevlieghere added inline comments.Sep 26 2017, 1:46 PM
llvmbisect/llvmlab/gcs.py
15 ↗(On Diff #116681)

Maybe we should call this HttpSession to emphasize that we will need a new instance each time?

vsapsai added inline comments.Sep 26 2017, 2:58 PM
llvmbisect/llvmlab/gcs.py
15 ↗(On Diff #116681)

In this code it doesn't really matter if you create a new instance or reuse the old one. In most places I decided to create a new instance because it is simpler.

I've chosen name HttpClient because client.get(...) seems more natural compared to session.get(...). I have to acknowledge my preferences are influenced by Java (e.g. org.apache.http.impl.client.CloseableHttpClient, okhttp3.OkHttpClient). Though looks like in Python "client" is also popular according to renaming httplib to http.client.

JDevlieghere added inline comments.Sep 27 2017, 4:10 AM
llvmbisect/llvmlab/gcs.py
15 ↗(On Diff #116681)

Fair enough, if it doesn't matter I'm totally fine with naming it client!

53 ↗(On Diff #116681)

Any argument against moving this up and having all the functions reusing this single instance?

vsapsai added inline comments.Sep 27 2017, 10:21 AM
llvmbisect/llvmlab/gcs.py
53 ↗(On Diff #116681)

No argument against it. I'll move and test.

HttpClient was intended to be stateful so I tried to avoid sharing. But based on current implementation we can safely share it and if necessary, it is possible to have a separate client.

cmatthews accepted this revision.Sep 27 2017, 10:37 AM

Looks good to me. Please address JDevlieghere's concerns and commit.

This revision is now accepted and ready to land.Sep 27 2017, 10:37 AM
vsapsai updated this revision to Diff 116890.Sep 27 2017, 2:59 PM
  • Address JDevlieghere feedback: use shared HttpClient in all methods.
This revision was automatically updated to reflect the committed changes.