celery - Pass a reference to a file rather than a file itself with Python -


i can't seem identify how create file in python , pass around reference file in order convert different image resolutions.

i'm using celery generate these various image resolutions asynchronously , passing entire image consumes memory , causes out of memory errors.

any suggestions on how should accomplish this? here's code illustration:

file_object = open('/tmp/image.jpg', 'w+')  api.fetch_remote_file() f:      file_object.write(f.read())     file_object.seek(0)      # pass file object through chain of functions generate new images     chain = generate_images.s(file_object, "high") | generate_images.s(file_object, "medium") | delete_temp(file_object)     chain()    # celery task process images asynchronously queue @app.task def generate_images(file_object, quality):      #convert image lower resolution , store     image = convert(file_object.read())      return file_object, image 

you can pass absolute path of file celery workers. , let worker open file , read content.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -