Matt N.
Matt N.

Reputation: 1239

Fun with GAE: urlfetch rpc time out

I'm trying to write an image to the blob store. I've tried fetch_response = urlfetch.fetch(image_url, deadline=10) which timed out and now I'm trying rpc with the same result. Can someone tell me what's wrong with the following code? Thanks for your help:

    media_items = ['logo.png']
    content_type = 'image/png'
    for media_item in media_items:
        image_url = 'http://localhost:8080/image/' + media_item
        #fetch_response = urlfetch.fetch(image_url, deadline=10)
        rpc = urlfetch.create_rpc(deadline=20)
        urlfetch.make_fetch_call(rpc, image_url)
        try:
            file_data = rpc.get_result()
            file_name = files.blobstore.create(mime_type=content_type)
            with files.open(file_name, 'a') as f:
                f.write(file_data)
            files.finalize(file_name)
            blob_key = files.blobstore.get_blob_key(file_name)
            create_media_item(blob_key)
        except urlfetch.DownloadError:
            logging.error('DownloadError')

This is running on my machine and if I look at the picture in the browser using this URL it displays. My logging.error() is printed.

Upvotes: 1

Views: 275

Answers (2)

Chris Farmiloe
Chris Farmiloe

Reputation: 14185

If you are fetching the blob from your own application, you should probably use BlobReader or load the file from the file system.

Upvotes: 3

Matt N.
Matt N.

Reputation: 1239

As it seems the dev server is single threaded and you have to run 2 instaces if you want to send requests to it:

GoogleAppEngine urlfetch timeout exception

Upvotes: 1

Related Questions