IOError 35 when trying to read the result of call to urllib2.urlopen

Discussion in 'Python' started by matt, Sep 10, 2011.

  1. matt

    matt Guest

    I'm using urllib2's urlopen function to post to a service which should
    return a rather lengthy JSON object as the body of its response.
    Here's the code:

    {{{
    ctype, body = encode_multipart(fields, files)
    url = 'http://someservice:8080/path/to/resource'
    headers = {'Content-Type': ctype, 'Content-Length': str(len(body))}
    req = urllib2.Request(url, body, headers)
    resp = urllib2.urlopen(req)

    resp_body = resp.read()
    }}}

    When I try to look at "resp_body" I get this error:

    IOError: [Errno 35] Resource temporarily unavailable

    I posted to the same URI using curl and it worked fine, so I don't
    think it has to do with the server.

    Any thoughts?
    matt, Sep 10, 2011
    #1
    1. Advertising

  2. matt wrote:

    > When I try to look at "resp_body" I get this error:
    >
    > IOError: [Errno 35] Resource temporarily unavailable
    >
    > I posted to the same URI using curl and it worked fine, so I don't
    > think it has to do with the server.


    Are your Python code and curl both using the same proxy? It may be that one
    is going direct and the other is using a proxy.

    Or perhaps the destination is just flaky, and the resource genuinely is
    temporarily unavailable. Or it doesn't like your useragent string and is
    lying.


    --
    Steven
    Steven D'Aprano, Sep 10, 2011
    #2
    1. Advertising

  3. matt

    matt Guest

    On Sep 9, 6:02 pm, Steven D'Aprano <steve
    > wrote:
    > matt wrote:
    > > When I try to look at "resp_body" I get this error:

    >
    > > IOError: [Errno 35] Resource temporarily unavailable

    >
    > > I posted to the same URI using curl and it worked fine, so I don't
    > > think it has to do with the server.

    >
    > Are your Python code and curl both using the same proxy? It may be that one
    > is going direct and the other is using a proxy.
    >
    > Or perhaps the destination is just flaky, and the resource genuinely is
    > temporarily unavailable. Or it doesn't like your useragent string and is
    > lying.
    >
    > --
    > Steven


    No proxy. It's all local over the loopback interface (probably should
    have mentioned that). The service I'm POSTing to is a Python web app
    with CherryPy as the framework. Also, because of some dependency
    issues I'm using Python 2.6.
    matt, Sep 10, 2011
    #3
    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. Xu, C.S.
    Replies:
    5
    Views:
    457
    John J. Lee
    Sep 17, 2003
  2. Matt
    Replies:
    0
    Views:
    2,670
  3. Chris
    Replies:
    0
    Views:
    1,029
    Chris
    Jul 10, 2005
  4. koranthala

    Urllib2 urlopen and read - difference

    koranthala, Apr 15, 2010, in forum: Python
    Replies:
    3
    Views:
    2,963
  5. Replies:
    5
    Views:
    100
Loading...

Share This Page