开发者

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']
    con开发者_Python百科tent_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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜