Celery - TypeError: Object of type bytes is not JSON serializable
Celery - TypeError: Object of type bytes is not JSON serializable
所以我尝试寻找一些答案,例如(,here and ),但解决方案没有任何意义。我正在向 Celery 发送字节。出于某种原因,它告诉我它是 JSON-可序列化的,而我什至没有使用 JSON
write_file_aws.delay(file_full_name, file_to_put) #file_fill_name - str type, file_to_put - bytes type
我遇到了错误我也尝试对其进行解码但是我遇到了这个问题
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 113: invalid continuation byte
所以我试了这个 solution 只是另一个错误。为什么我不能将字节类型的变量发送给芹菜?那是不可能发送给 celery 函数的东西吗?
后端框架- Flask。
简单的答案是您不能将字节类型变量传递给 Celery 函数。如果必须,可以将其转换为列表,将其保存在数据库中,然后在函数内部调用它。或者将其编码为 base64,然后在 thr 函数中对其进行解码。
所以我尝试寻找一些答案,例如(
write_file_aws.delay(file_full_name, file_to_put) #file_fill_name - str type, file_to_put - bytes type
我遇到了错误我也尝试对其进行解码但是我遇到了这个问题
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 113: invalid continuation byte
所以我试了这个 solution 只是另一个错误。为什么我不能将字节类型的变量发送给芹菜?那是不可能发送给 celery 函数的东西吗?
后端框架- Flask。
简单的答案是您不能将字节类型变量传递给 Celery 函数。如果必须,可以将其转换为列表,将其保存在数据库中,然后在函数内部调用它。或者将其编码为 base64,然后在 thr 函数中对其进行解码。