-1

I use Appengine standard with:

basic_scaling:
  max_instances: 7
  idle_timeout: 4m

instance_class: B4_1G

i try to rotate an image:

def get_image(bucket_name, file_name):   
    blob = storage_client.bucket(bucket_name).get_blob(file_name)
    _, temp_local_filename = tempfile.mkstemp()
    blob.download_to_filename(temp_local_filename)
    with Image(filename=temp_local_filename) as i:
      encoded_image = base64.b64encode(open(i.rotate(125), 'rb').read())
      del i

  gc.collect()    
  return (html.Img(src='data:image/png;base64,{}'.format(encoded_image.decode('utf-8')), style={'height':'400%', 'width':'100%'}))

but i get:

 File "/layers/google.python.pip/pip/lib/python3.8/site-packages/wand/resource.py", line 222, in raise_exception
    raise e
wand.exceptions.CacheError: cache resources exhausted `/tmp/tmp0gu_437j' @ error/cache.c/OpenPixelCache/3984

on the rotate line.

schoon
  • 2,858
  • 3
  • 46
  • 78
  • Bear in mind that App Engine Standard stores all files in /tmp directory in the instance's RAM, therefore writing to /tmp takes up system memory, as documented [here](https://cloud.google.com/appengine/docs/standard/python3/using-temp-files) – LundinCast Jan 13 '21 at 11:54
  • Not a memory error, but a lack of system resources to complete the task. Can you describe the image that's failing? – emcconville Jan 13 '21 at 11:58
  • It is a 1MB jpeg. – schoon Jan 13 '21 at 12:00
  • @Lundincast. Thanks, any way of increasing it? – schoon Jan 13 '21 at 12:02
  • RAM is dependent on the [instance class](https://cloud.google.com/appengine/docs/standard#instance_classes) you define on your `app.yaml` file. You are already using an instance class with the highest RAM value available (2GB), as the `B8` instance class offers only more CPU power. You can scale based on concurrent requests and CPU utilization. Glad you sorted out the issue by rotating 90º. – Daniel Ocando Jan 13 '21 at 14:43

1 Answers1

0

i.rotate(125) gives the error, but i.rotate(90) works, as does 270. I only want 90-degree rotations so that will do.

schoon
  • 2,858
  • 3
  • 46
  • 78