urllib slow on Leopard

Discussion in 'Python' started by mark, Feb 24, 2008.

  1. mark

    mark Guest

    I've recently switched from Ubuntu to OS X Leopard. I have some python
    scripts which download info from the web. The scripts were working fine
    before on Ubuntu, but urllib seems to work really slowly on Leopard.

    I tried an example from the docs:

    >>> import urllib2
    >>> f = urllib2.urlopen('http://www.python.org/')
    >>> print f.read(100)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtm
    >>>


    The line f = ... takes about a minute to return - but otherwise returns
    the predicted result. My web connection seems fine, so has anyone got
    any ideas as to what the problem might be?
    mark, Feb 24, 2008
    #1
    1. Advertising

  2. mark

    André Guest

    On Feb 24, 3:57 pm, mark <> wrote:
    > I've recently switched from Ubuntu to OS X Leopard. I have some python
    > scripts which download info from the web. The scripts were working fine
    > before on Ubuntu, but urllib seems to work really slowly on Leopard.
    >
    > I tried an example from the docs:
    >
    > >>> import urllib2
    > >>> f = urllib2.urlopen('http://www.python.org/')
    > >>> print f.read(100)

    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtm
    > >>>

    >
    > The line f = ... takes about a minute to return - but otherwise returns
    > the predicted result. My web connection seems fine, so has anyone got
    > any ideas as to what the problem might be?


    Nope, but it's not Leopard related. Just checked here and it loaded
    in about 1 sec.

    André
    André, Feb 24, 2008
    #2
    1. Advertising

  3. mark wrote:
    > I've recently switched from Ubuntu to OS X Leopard. I have some python
    > scripts which download info from the web. The scripts were working fine
    > before on Ubuntu, but urllib seems to work really slowly on Leopard.
    >
    > I tried an example from the docs:
    >
    >>>> import urllib2
    >>>> f = urllib2.urlopen('http://www.python.org/')
    >>>> print f.read(100)

    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtm
    >>>>

    >
    > The line f = ... takes about a minute to return - but otherwise returns
    > the predicted result. My web connection seems fine, so has anyone got
    > any ideas as to what the problem might be?


    It likely tries to load the DTD in the background, which requires network access.

    http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic

    Stefan
    Stefan Behnel, Feb 24, 2008
    #3
  4. mark

    mark Guest

    mark wrote:
    > I've recently switched from Ubuntu to OS X Leopard. I have some python
    > scripts which download info from the web. The scripts were working fine
    > before on Ubuntu, but urllib seems to work really slowly on Leopard.
    >
    > I tried an example from the docs:
    >
    > >>> import urllib2
    > >>> f = urllib2.urlopen('http://www.python.org/')
    > >>> print f.read(100)

    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtm
    > >>>

    >
    > The line f = ... takes about a minute to return - but otherwise returns
    > the predicted result. My web connection seems fine, so has anyone got
    > any ideas as to what the problem might be?


    I found that by configuring the network manually (specifying static IP
    address, etc.) it sped the whole thing up. Go figure.
    mark, Feb 25, 2008
    #4
  5. mark

    Paul Boddie Guest

    Paul Boddie, Feb 26, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    3,011
  2. HK
    Replies:
    3
    Views:
    434
  3. Jonathan Gardner

    Asynchronous urllib (urllib+asyncore)?

    Jonathan Gardner, Feb 26, 2008, in forum: Python
    Replies:
    1
    Views:
    462
    Terry Jones
    Feb 27, 2008
  4. Chris McDonald
    Replies:
    0
    Views:
    275
    Chris McDonald
    Nov 1, 2010
  5. Chris Shea
    Replies:
    18
    Views:
    164
    Roger Pack
    Feb 8, 2008
Loading...

Share This Page