简体   繁体   中英

Celery - TypeError: Object of type bytes is not JSON serializable

So I tried looking for some answer eg( here , here and here ) but the solutions don't make any sense. I am sending bytes to Celery. and for some reason it tells me that it's JSON-serializable while I am not even using JSON

write_file_aws.delay(file_full_name, file_to_put) #file_fill_name - str type, file_to_put - bytes type

and there I have the error I tried also decoding it but I had this problem

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 113: invalid continuation byte

so I tried this solution and just another error. Why can't I send a byte-type variable to celery? Is that something impossible to send to a celery function?

backend framework- Flask.

The simple answer is that you just can't pass a byte type variable to a Celery function. If you have to you can turn it to a list save it in a database then call it inside the function. Or encode it to base64 and then in thr function decode it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM