Frage

I am writing a piece of code that uses the Box.com Python SDK. The SDK uses the requests module to communicate with Box.com as per the API documentation. For my purposes, I need to make several GET and POST requests in a row, some of which could be used to transfer files. The issue that I'm running into is this:

  • On Linux (Ubuntu 13.10), each request takes a relatively long time (5 to 15 seconds) to get through, though transfer speeds for file transfers are as expected in the context of my network connection.
  • On Windows 8.1, running the exact same code, the requests go through really fast (sub-second fast).

On both platforms I am using the same version of iPython (1.1.0) and of the requests module (1.2.3) under Python 2.7. This is particularly problematic for me because the code I'm working on will eventually be implemented on Linux machines.

Is this problem someone has encountered before? I would love to hear from anyone with some ideas on what the issue might be. I have yet to try it on a different Linux installation to see if it is a problem with the specific setup.

Thanks.

EDIT 1

So, I decided to check this using virtual machines. Using the same Debian virtual machine under Windows all the responses were fast, but under Ubuntu they were slow. I then made a Ubuntu 12.04 live USB and ran the code on that, and the responses were fast there as well.

So, it's not Python or Linux in general, it's my particular installation and I have no idea how to diagnose the problem :(

War es hilfreich?

Lösung

Use a tool such as wireshark (which needs to be run with sudo on most distributions) to log the individual network packets when your code makes the API requests, to determine what is taking so long.

My guess is the following possibilities are most likely:

  1. For some reason your Ubuntu installation is picking up the wrong DNS server list, and DNS lookups are timing out.
  2. IPv6 issue (which may appear to be a DNS issue, too). Disable IPv6.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top