python - Erratic problem with App Engine when writing files directly to the blobstore -


i'm using app engine python. in order store images of users, write them directly blobstore indicated in google documentation.

my code below:

# image insertion in blobstore file_name = files.blobstore.create(mime_type='image/jpeg') files.open(file_name, 'a') f:     f.write(self.imagecontent) files.finalize(file_name) self.blobkey = files.blobstore.get_blob_key(file_name) logging.info("blobkey: "+str(self.blobkey)) 

the problem erratic. don't change , since yesterday works doesn't work. why? print blobkey (last line of code), can see whether image has been saved blobstore or not.

when works, have following line displayed:

blobkey: amifv94p1cfdqkza3ahzuf2tf76szvewpggwopn... 

when doesn't work, have in logs:

blobkey: none 

last detail: images (self.imagecontent) preprocessed , converted .jpeg before each write.

edit:
everytime, images stored in blobstore (i can see them in blobviewer in administration console). that's get_blob_key function malfunctioning...

i know should in such situation? doing wrong makes app engine behavior erratic. how can solve out?

i managed solve problem making thread sleep during intervals of 50ms

this code added:

# blobkey none self.blobkey = files.blobstore.get_blob_key(file_name)  # have make wait til works! in range(1,3):     if(self.blobkey):          break     else:         logging.info("blobkey still none")         time.sleep(0.05)         self.blobkey = files.blobstore.get_blob_key(file_name)  logging.info("blobkey: "+str(self.blobkey)) 

of course, have import time module make work.

import time 

i pretty did same person in issue 4872 systempuntoout mentioned.

thanks. please feel free add suggestion.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -