2

I am running a python script that uses request.get() to retrieve data from various online sources. The script runs very well on my Macbook Pro. But when I run the same python script on my new Windows 10 machine, it takes about 6x as long to make the same request calls.

Anyone have some insight into why this might be happening, and how to solve it?

Edit[1]:

To add a sample of the code I'm using, here is the simple class that does the requests:

import requests

def getHTTPRequest(url, mTimeout):
  response = requests.get(url, timeout=mTimeout)
  return response.content
Leif
  • 107
  • 1
  • 11
  • 2
    Probably a network issue. – masnun Aug 18 '16 at 21:04
  • @Leif can you repeat the test 10 times on each platform and give us the mean on both? One time it may have been the network. – limbo Aug 18 '16 at 21:06
  • you may also want to compare network adapters and see if one is faster than the other. E.g one using 802.11n vs 802.11 b , or maybe one is on a 2.4 GHz channel with lots of interference and the other on 5GHz. Once you make sure that the two machines achieve similar speeds in general then we should look into software. – limbo Aug 18 '16 at 21:09
  • Hey all, both my Mac and Windows machines are running the script on the same network. I've run the script on both computers making over 1000 request.get() calls each. The windows 10 machine takes 6x more time per call on average. ~ Mac Avg: 6 sec per request ~ Win Avg: 60 sec per request – Leif Aug 18 '16 at 21:24
  • Could you add some of the code that demonstrates the problem? – Antti Haapala -- Слава Україні Aug 18 '16 at 21:37
  • I added the code that does the requests. The url passed in is not relevant, as both Mac and Windows are using the same url/ – Leif Aug 18 '16 at 21:51
  • Try running ping to see what sort of delays are on both. If you see delays from ping that match similar to what you see in requests library, it's a network issue. Otherwise it *could* be a python issue. – NuclearPeon Aug 18 '16 at 21:54
  • I think this is a network issue. Make sure you are connected to a good network. Try to use a "good" website such as `http://www.google.com`. I dobut that this is a library problem, but make sure you have the latest version of `requests`. offtopic: you can (and maybe should) use `return requests.get(url, timeout=mTimeout).content`. – Xiobiq Aug 18 '16 at 22:01
  • Assuming you are doing this over wifi: on Windows: go to "Device Manager: -> "Network Adapters" -> select adapter for Wifi -> "Advanced" -> tell us what mode is it running on/what adapter you have. EDIT: you may want to do this test with a wired connection since you can get very different performances from wifi cards. – limbo Aug 18 '16 at 22:01
  • How are you sure that requests.get is taking longer? Did you that request alone? Also are there any network paths in your PYTHONPATH – be_good_do_good Aug 19 '16 at 01:35
  • 1
    Have there been any developments on this? I'm having the same problem right now. On mac python requests and in chrome (mac or windows), my GET call takes 1.5 seconds but on Windows 10, requests.get takes 7.5 seconds. – josneville Apr 05 '17 at 21:08
  • Hey @josneville I never solved this issue. I just ran all my operations from my mac :( Project only lasted a month or so I never was forced to fix it. – Leif Nov 08 '18 at 01:21
  • Do you know what version python (14, 15) and which version of requests? – Hywel Thomas May 01 '19 at 15:09
  • @HywelThomas Hey, sorry this issue is so old, that I cant remember which python version it was. – Leif Oct 17 '19 at 22:04
  • I'm having a similar issue with a requests.post call to a Graphql API (Dynamic Odds). The offending command is request = requests.post(api_query_endpoint_url, json={'query': query}, headers=api_call_headers). Same procedure using Python3.10 on iMac (i5) took elapsed_time: 159.9secs (less than 3 mins) whereas Win10 (i7) took astronomically longer elapsed_time: over 30 mins!! – Mr Ed Oct 27 '21 at 00:39

0 Answers0