0

I'm currently using Python 2.7 and the requests module to upload files via HTTP POST requests in a little script of mine.

All things considered, the script is doing its job but sometimes the servers on the other end are quite slow and I want to abort the upload process after a certain amount of time (e.g. after 60 seconds). I looked into the timeout function in the requests module but that only applies to the response time of the server, not the actual transmission time period.

So, actually, I've got two questions:

1) Do you know a solution to my problem or an already existing module out there that I could use?

2) Also, do you know if it's a Python problem that upload speeds via Python script are kind of slow compared to uploads using the browser (3-5 Megabyte/s vs. 20-30 Megabytes/s; I'm using a server)?

If this questions is a duplicate, please bear with me. I used the search but no thread was spot-on.

clinch
  • 31
  • 3
  • http://stackoverflow.com/questions/265720/http-request-timeout would this be useful? – Mo H. Mar 03 '15 at 20:36
  • How about wrapping the function you have with this timeout decorator: http://stackoverflow.com/questions/2281850/timeout-function-if-it-takes-too-long-to-finish – Rafael Barros Mar 03 '15 at 20:36
  • @RafaelBarros thanks but actually, this solution works only on UNIX systems but my script is running on a windows machine :( – clinch Mar 04 '15 at 20:18

0 Answers0