1

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.

Matt N.
  • 1,239
  • 2
  • 11
  • 26
  • 1
    Use `logging.exception` instead of `logging.error`, and your log message will include the stacktrace and exception information. – Nick Johnson Jul 26 '11 at 01:56

2 Answers2

3

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

Chris Farmiloe
  • 13,935
  • 5
  • 48
  • 57
1

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

Community
  • 1
  • 1
Matt N.
  • 1,239
  • 2
  • 11
  • 26